Prajowola.
Let's Talk
Back to Projects

Source code

Snake

Steer the snake with the arrow keys or on-screen controls, eat the food to grow, and avoid hitting the walls or yourself. Built with the HTML canvas and a game loop.

Built with

HTMLCSSJavaScript (Canvas)

The download is a single self-contained .html file — all the markup, styling, and game logic live in one place, with no libraries or build tools.

Main features

  • Fixed-step game loop driving smooth grid-based movement.
  • Arrow-key, WASD, and on-screen touch controls.
  • Live score and instant restart after game over.

How to run it on your device

  1. 1. Click Download source code above to save the .html file.
  2. 2. Double-click the file (or right-click → Open with → your browser).
  3. 3. The game runs instantly — no installation, no internet connection needed.
  4. 4. Want to peek inside? Open the same file in any text editor to read and tweak the code.