Skip to content

Instantly share code, notes, and snippets.

@kamkom
Created June 21, 2026 10:43
Show Gist options
  • Select an option

  • Save kamkom/da5e083dac78ccd32e69d9317d70db6a to your computer and use it in GitHub Desktop.

Select an option

Save kamkom/da5e083dac78ccd32e69d9317d70db6a to your computer and use it in GitHub Desktop.
snake-spec
# Specification: Browser-Based Snake Game
## 1. Overview
The application is a simple browser-based Snake game. The player controls a snake that moves around the game area, collects food, and gains points. The game ends when the player reaches **10 points**, collides with the wall, or collides with the snake’s own body.
## 2. Game Objective
The objective is to collect food items to increase the score. Each collected food item gives the player **1 point**. When the player reaches **10 points**, the game ends successfully.
## 3. Platform
The game will run in a modern web browser and should be playable using a keyboard.
Supported browsers:
* Google Chrome
* Mozilla Firefox
* Microsoft Edge
* Safari
## 4. Controls
The player controls the snake using the keyboard arrow keys:
* Arrow Up: move up
* Arrow Down: move down
* Arrow Left: move left
* Arrow Right: move right
The snake cannot immediately reverse direction.
## 5. Game Rules
* The snake moves continuously in the current direction.
* Food appears randomly inside the game area.
* When the snake eats food:
* The score increases by 1.
* The snake grows longer.
* A new food item appears in a random empty location.
* The game ends when:
* The score reaches 10 points.
* The snake hits the wall.
* The snake hits itself.
## 6. Scoring
* Each food item is worth 1 point.
* The maximum score is 10.
* When the score reaches 10, the player wins and the game stops.
## 7. User Interface
The game screen should include:
* A game board
* The snake
* The food item
* A visible score counter
* A game-over message
* A restart button
## 8. Game Over Messages
Possible messages:
* “You win! Score: 10” when the player reaches 10 points.
* “Game over!” when the player collides with a wall or itself.
## 9. Restart Functionality
After the game ends, the player should be able to restart the game. Restarting should reset:
* Snake position
* Snake length
* Score
* Food position
* Game state
## 10. Technical Requirements
The game should be implemented using standard web technologies:
* HTML
* CSS
* JavaScript
No backend server is required.
## 11. Acceptance Criteria
The game is considered complete when:
* The snake can be controlled with arrow keys.
* Food appears randomly on the board.
* The score increases after eating food.
* The snake grows after eating food.
* The game ends after reaching 10 points.
* The game ends after wall or self-collision.
* The player can restart the game.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment