AI 生成: A classic Snake game built with HTML, CSS, and JavaScript. Control the snake to eat food, grow longer, and avoid hitting walls or yourself.
This commit is contained in:
@@ -0,0 +1,49 @@
|
||||
# Snake Game
|
||||
|
||||
A classic Snake game built with pure HTML, CSS, and JavaScript. No dependencies, no build step — just open and play.
|
||||
|
||||
## Features
|
||||
|
||||
- Smooth grid-based snake movement
|
||||
- Score tracking with persistent high score (localStorage)
|
||||
- Keyboard controls (Arrow keys or WASD)
|
||||
- Game over detection (walls & self-collision)
|
||||
- Restart button
|
||||
- Responsive, clean retro-style UI
|
||||
|
||||
## Project Structure
|
||||
|
||||
```
|
||||
snake-game/
|
||||
├── index.html # Main HTML page
|
||||
├── css/
|
||||
│ └── style.css # Game styling
|
||||
├── js/
|
||||
│ └── game.js # Game logic
|
||||
└── README.md
|
||||
```
|
||||
|
||||
## How to Play
|
||||
|
||||
1. Open `index.html` in any modern web browser.
|
||||
2. Use the **Arrow keys** or **WASD** to control the snake.
|
||||
3. Eat the red food pellets to grow and earn 10 points each.
|
||||
4. Avoid hitting the walls or your own body.
|
||||
5. Click **Restart** to start a new game.
|
||||
|
||||
## Development
|
||||
|
||||
No installation required. Simply clone or download the project and open `index.html`.
|
||||
|
||||
If you prefer a local server:
|
||||
|
||||
```bash
|
||||
# Python 3
|
||||
python -m http.server 8000
|
||||
|
||||
# Then open http://localhost:8000
|
||||
```
|
||||
|
||||
## License
|
||||
|
||||
MIT
|
||||
Reference in New Issue
Block a user