Skip to main content

8bit Mario with css grids

The point of this task was to get more familiar with css grids. I aimed to use as little divs as possible but I wanted it to be to scale. 

You can view it below or on Codepen.

See the Pen mario with grids by Mel (@Mellydevs) on CodePen.

Making Mario

As I was making a 8bit character I made a 64 by 64 grid and made each grid size 8px by 8px. This allowed me to make Mario to scale. 
NB: I do not own anything to do with Mario I am just a fan :).



So after using reference images I managed to make divs turn into Mario by changing their position in the grid and background colour. If you want to learn more about grids I recommend css tricks article on it or Grid garden which is a game that helps you learn grids. It turned out quite good and I was happy with it.

I thought I was done but then....

I thought why not make him do a idle animation, So I looked at some sprite sheets (whats a sprite sheet?) Kirby's idle seemed to be the easiest so I chose to try and achieve that. So my idea was to loop through the parts I wanted to move and make them go down one so it would create a squish motion and then go back to normal.

I did this by setting the ending placement of the blocks by using &.resting in sass then I used a set interval to loop around the divs to toggle off and on the class - creating a resting motion.

Which is cool but can we make it better ?

Yes is the answer, so I added a floor  and a sky and now I might as well make it into a game.



Gaming time

So I will be basically be re-creating the chrome dino game when you are offline. As I know what grid Mario is in I can check when the box reaches it and check if Mario is jumping. If he is jumping and the box makes it passed Mario the game continues and adds to your score, if not game over.

I will be moving the box with another setInterval and once it reaches the end (i < 2) I will reset it back to the start. If it hits then It will give the user a message saying 'game over' and reset the game.  

I then moved onto the jumping and did the styles that will be added when you hit the up key (or button) for an amount of time then it will be removed.

I also added a counter for every box you jump to add some method of scoring and I will also be using this count to increase the speed of the box to make it harder as time goes on. I've also added a high score that will save the users highs score to the local storage on their client. I didn't really have a style in mind for this I just went for simple and 8bit (kinda :P).

Thanks for reading, this was a practically fun Sunday funday project and I am happy with it. If you have any suggestion's leave a comment or if you liked it let me know :). 

Comments

Popular posts from this blog

Ionic RSS feed using Feednami

Tutorial of how to make a RSS feed using Feednami which is an alternative to google api which no longer works. This is a basic example and can be improved. First go ahead and make a new ionic project $ npm install -g cordova ionic $ ionic start exampleProject blank Now find index.html and insert... <script src="https://storage.googleapis.com/feednami-static /js/feednami-client-v1.0.1.js"></script> Into the header, then in <ion-content> below Ionic Blank Starter insert a new div <div id ="feed" ng-controller="feedCtrl"> </div> Open app.js, now we are going to make the controller from Feednami that will get our rss feed. .controller('feedCntl', function(){ var url = 'http://daringfireball.net/feeds/articles' feednami.load(url,function(result){ if(result.error){ console.log(result.error) } else{ var entries = result.feed.entries for(var i = 0; i < entri...

Google daydream and all its awesomeness.

Google Daydream  At Google io in 2016,  Google announced: Google daydream. A platform that can bring VR to everyone throughout the use of mobile phones and their new viewer. I was so inspired watching this I felt a need to make Daydream content. However to be able to develop this you need a Google view (£69 from Google store) and a daydream ready phone (£599 and up from Google store). I still plan to do this and will be buying a red viewer very soon (Im so excited XD) and will do an unboxing so look out for that! Then I will be saving up for the pixel phone (which is beautiful) and then onward with making awesomeness. Developing awesomeness  Its not just awesome because of the new viewer and the new pixel phone but the amount of help from google for developers is amazing they already have SDK kits for Android, Unity and Unreal. Unity and Unreal and two powerful game engines both have pros and cons but both are great for making games. I have experie...

BBC micro bit go un-boxing

The BBC micro bit  A while ago I attended Hacksoton  which is a hack day in Southampton, UK. It was a great day and I got to see and hear new and interesting technology (I would recommend for children and developers in the area). One of these technologies was the BBC Micro bit  . What is it for?  Its designed to get children into coding, you can use python, javascript or block editors. I loved them so much that I decided to get myself one as it can also be used with raspberry pi. So below is a video of me opening my micro bit go and I hope to do many exciting projects in the upcoming year and will be writing up about them so keep an eye out! What would you like to see with the micro bit? let me know in the comments below.