Last Updated: 3/6/2026
Game Mechanics
Detailed explanation of how the Snake Game works, including rules, progression, and unique features.
Core Rules
Objective
Eat as much food as possible without colliding with walls or yourself.
Movement
- Snake moves continuously in the current direction
- Direction changes take effect on the next update
- Cannot reverse direction (e.g., can’t go LEFT if moving RIGHT)
- Movement is grid-based (one cell per update)
Food
- One food item spawns at a time
- Food appears at a random empty grid position
- Eating food:
- Increases score by 1
- Increases snake length by 1 segment
- Spawns new food immediately
Collision
Game ends if snake collides with:
- Grid boundaries (walls)
- Its own body (any segment)
Note: The head can occupy the same cell as the tail on the same frame (tail moves away first), so wrapping around yourself is possible in tight spaces.
Progression System
Grid Expansion
Unlike traditional Snake, this game features dynamic grid scaling:
-
Trigger: Snake fills ≥25% of the grid
fillPercentage = snakeLength / (gridSize × gridSize) if fillPercentage ≥ 0.25: expandGrid() -
Expansion: Grid doubles in size
- 10×10 → 20×20 → 40×40 → 80×80 (theoretical max)
- Snake position and direction preserved
- Food respawns at new random position
-
Level Up: Level increments by 1
-
Speed Increase: Game speed doubles
- Initial: 200ms per update (5 updates/second)
- Level 2: 100ms (10 updates/second)
- Level 3: 50ms (20 updates/second)
- Level 4: 25ms (40 updates/second)
Difficulty Curve
| Level | Grid Size | Speed (ms) | Updates/sec | Approx. Food to Advance |
|---|---|---|---|---|
| 1 | 10×10 | 200 | 5 | 25 |
| 2 | 20×20 | 100 | 10 | 100 |
| 3 | 40×40 | 50 | 20 | 400 |
| 4 | 80×80 | 25 | 40 | 1,600 |
Note: Higher levels become exponentially harder due to:
- Larger grid (more space to navigate)
- Faster movement (less reaction time)
- Longer snake (more obstacles)
Scoring
- 1 point per food eaten
- No time bonus or combo system
- Score persists across levels
- High score saved to localStorage
Score Milestones
- 25: Reach level 2 (20×20 grid)
- 125: Reach level 3 (40×40 grid)
- 525: Reach level 4 (80×80 grid)
Controls
Movement
| Input | Direction |
|---|---|
| ↑ / W | Up |
| ↓ / S | Down |
| ← / A | Left |
| → / D | Right |
Input buffering: The next direction is queued and applied on the next update, allowing rapid direction changes.
Game Control
| Key | Action |
|---|---|
| Enter | Start new game (from menu or game over) |
| R | Restart (anytime) |
| P | Pause / Resume |
Pre-Game Settings
Before starting a game, adjust grid size:
| Key | Action |
|---|---|
| + / = | Increase grid size by 5 (max 50×50) |
| - / _ | Decrease grid size by 5 (min 5×5) |
Note: This only affects the starting grid size. The grid still doubles on level up.
View Controls
Anytime (even during gameplay):
| Key | Action |
|---|---|
| Q | Rotate view clockwise |
| E | Rotate view counter-clockwise |
| [ | Decrease perspective strength |
| ] | Increase perspective strength |
Tip: Adjust the view to find the angle that works best for you!
Unique Features
1. Isometric 3D View
- Pseudo-3D rendering with depth perception
- Fully rotatable camera (Q/E keys)
- Adjustable perspective strength ([ and ] keys)
- Smooth, rotation-invariant scaling
2. Grid Expansion
- Infinite progression potential
- Difficulty scales naturally
- No arbitrary level cap
- Strategic depth: balance growth vs. safety
3. Adjustable Grid Size
- Customize starting difficulty
- Smaller grids: faster-paced, cramped
- Larger grids: more strategic, slower start
- Affects progression curve
4. Pause Anytime
- No penalty for pausing
- Useful for planning next moves
- Overlay shows game state
Strategy Tips
Early Game (Level 1-2)
- Fill efficiently: Move in a spiral or snake pattern to cover the grid
- Stay centered: Avoid corners to maximize escape routes
- Plan ahead: Anticipate where food will spawn
Mid Game (Level 3-4)
- Use the space: Larger grids give more room to maneuver
- Create safe zones: Leave open areas to retreat into
- Avoid the tail chase: Don’t box yourself in
Late Game (Level 5+)
- Slow down mentally: The game is fast, but you need to think ahead
- Peripheral vision: Track your tail and food simultaneously
- Emergency escapes: Always have a backup route
Advanced Techniques
The Spiral
Move in concentric circles to fill the grid efficiently:
┌──────────┐
│→→→→→→→→→↓│
│↑┌──────┐↓│
│↑│→→→→→↓│↓│
│↑│↑┌──┐↓│↓│
│↑│↑│ │↓│↓│
│↑│↑└──┘↓│↓│
│↑│└─────┘│↓│
│↑└────────┘│
└──────────┘The Zigzag
Alternate horizontal passes to cover the grid:
┌──────────┐
│→→→→→→→→→↓│
│ ↓│
│←←←←←←←←←┘│
│↓ │
│└─→→→→→→→→→│
│ ↓│
│←←←←←←←←←┘│
│↓ │
└─┘ │The Wall Hug
Stay near edges to maximize open space in the center:
┌──────────┐
│→→→→→→→→→↓│
│↑ ↓│
│↑ ↓│
│↑ Open ↓│
│↑ Space ↓│
│↑ ↓│
│↑ ↓│
│↑←←←←←←←←┘│
└──────────┘Common Mistakes
1. Reversing Direction
Pressing the opposite direction does nothing (and wastes time).
Solution: Always move in an L-shape to reverse:
- Going RIGHT? Press UP then LEFT (not LEFT directly)
2. Corner Traps
Getting stuck in a corner with no escape.
Solution: Always leave yourself an exit route. Avoid corners unless necessary.
3. Tail Chasing
Following your own tail in circles.
Solution: Create open loops instead of closed spirals.
4. Panic Moves
Rapid, unplanned direction changes.
Solution: Pause (P key) to plan your next moves.
5. Ignoring Grid Expansion
Not adapting strategy when grid doubles.
Solution: After expansion, reassess your position and create new safe zones.
Future Mechanics (Planned)
From README2.md and README3.md:
Upcoming Features
- 2 snakes at once: Multiplayer or dual-control mode
- Power-ups: Speed boosts, invincibility, score multipliers
- Obstacles: Walls, moving hazards, teleporters
- Game modes: Time attack, survival, puzzle challenges
Community Requests
- Mobile support: Touch controls for phones/tablets
- Leaderboards: Online high score tracking
- Replays: Watch and share your best games
- Customization: Skins, themes, color schemes
Have questions or suggestions? Open an issue on GitHub!