A few years before the dawn of the iPhone, we all had Nokias with the addictive Snake game installed. The premise of snake was simple: eat all the food on the screen without hitting your tail or a wall. The more food you eat, the longer your tail became.
Paul Jensen has returned to that era for his addictive Snake canvas game, and has also provided a handy tutorial on how he created it.
Comments from the author:
The canvas element is used to map the playing area of the game where the Snake moves. The Snake consists of a collection of xy coordinates on the canvas element, and the movement is simulated by drawing and removing the xy coordinates from the canvas element.
The tutorial itself is a handy guide for those who are a little unsure of where to start when it comes to using user interactions to manipulate the canvas from reading the key pressed to checking your object is still within the boundaries of the canvas.