Skip to content

Ooskar7/snake-game

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Snake Game

A polished browser-based Snake game built with TypeScript, Vite, and HTML Canvas. The game keeps the core model separate from rendering so movement, food spawning, collision checks, and state transitions are covered by unit tests.

Technologies

  • TypeScript
  • Vite
  • HTML Canvas
  • Vitest
  • Local storage for high score persistence

Run Locally

npm install
npm run dev

Build

npm run build

Tests

npm run test:run

Controls

  • Arrow keys or WASD: change direction
  • Space: pause or resume
  • Enter or R: restart

Features

  • Grid-based Snake movement
  • Food spawning away from the snake
  • Growth and scoring after eating
  • Wall and self-collision game over
  • Pause, resume, and restart
  • Difficulty increases as score grows
  • Responsive canvas layout
  • Persistent high score

Possible Improvements

  • Add sound effects with a mute toggle
  • Add touch controls for mobile
  • Add selectable board sizes
  • Add a compact leaderboard stored locally

About

A polished browser-based Snake game built with TypeScript, Vite, HTML Canvas, and Vitest.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors