π A browser-based Snake game built with vanilla HTML, CSS, and JavaScript. No frameworks, no build tools, no network requests β just open and play.
- Open
index.htmlin any modern browser (Chrome, Firefox, Safari, Edge) - Click Start Game or press Enter
- Control the snake with Arrow Keys or WASD
- Collect food to grow and increase your score
- Avoid walls and your own tail
- Your highest score is automatically saved locally, so you can try to beat it next time you play!
| Action | Keys |
|---|---|
| Move | Arrow Keys / WASD |
| Pause | Escape / P |
| Resume | Escape / P / Resume button |
| Start / Restart | Enter / Button click |
- 20Γ20 grid with smooth movement
- Speed progression (10 levels) as you score
- High score persisted across sessions via
localStorage - Pause/resume with overlay
- Auto-pause on window blur
- Responsive layout (320pxβ1920px)
- Dark theme with accessible contrast ratios
- Win condition when the board is completely filled
βββ index.html # Game UI with three screens
βββ style.css # All styling and responsive layout
βββ game.js # Game logic, controller, and rendering
βββ package.json # Dev dependencies (fast-check for tests)
βββ tests/ # Property-based and unit tests
To install dependencies and run the test suite, execute the following commands in the project root:
npm install
npm testTests use the Node.js built-in test runner and fast-check for property-based testing. All 68 tests validate 12 correctness properties covering movement, collisions, scoring, input handling, and persistence.
This project is licensed under the MIT License.