
New food may appear under snake, uncoil to reveal.Ĭollect the food to grow and increase speed. HTML5 variation of the classic snake game.Ĭontrol snake with arrow keys, WASD, or HJKL (vim keys).
#Classic snake html code code
The Source Codeįor those that are interested, here is a quick overview of the code for this game.įirst, we need a basic page setup with a canvas tag. You can also view/play the game (in 640x480 mode) directly on jsfiddle.

If you are visiting this page in an HTML5 capable browser, and are not on a mobile device, then this game should work for you. I thought about snake again, and it hit me: the snake is an array, and shift()ing and push()ing coordinates would let it move properly, and when it got food, it could just skip the shift(). Getting the snake to turn corners was not as easy as lightcycles, so I abandoned snake and moved on, eventually creating several proof of concept game-like creations. Moving a box across the canvas was easy, and turning off the screen reset gave me lightcycles for free. Some variants include obstacles, increased speed, and other mechanisms to increase difficulty. The concept is simple: you control a snake that grows when it consumes food, and dies when it hits a wall or itself. Nokia put it on cell phones in 1998, and it became a staple of cell phone gaming. The whole truth behind the lightcycle game includes the tidbit that when I first started playing around with the creating that game, snake was my original intention.įor those that don’t know it, snake is one of the oldest video games, with origins in the 1970s. I wrote a blog post about the experience, you can check it out here.


It is a Tron inspired lightcycle game, a humble recreation of the 1980s arcade classic. Last month I made my first game: html5-lightcycles. Thank you HackerNews for the front-page love!
