Game guide
How to play the Canvas Snake game
Canvas Snake is a small JavaScript and HTML game by Ahsan Ayaz. The snake begins in the center of a 20×20 grid with a tail length of four. Eating the red apple adds one point, lengthens the tail and moves the apple to a new random square.
- Choose a direction. Press an arrow key to start moving and to steer left, up, right or down.
- Collect the red apple. Move the head onto the apple. Each apple grows the tail by one segment and increases the displayed score.
- Avoid your own tail. If the head reaches a square occupied by the body, the game returns the snake to its starting length and resets the score.
Arrow-key controls and wraparound edges
This version does not treat the outer wall as a collision. Moving past the left edge returns the snake on the right, and the same wraparound behavior applies vertically. Hitting the tail resets the position, tail length and score.
HTML5 Canvas source and license
The embedded demo is served from Ahsan Ayaz's GitHub Pages project. Its public repository contains the small Canvas implementation and an MIT license. Blockdeck links to that project and describes only the behavior visible in its source.
