by-idb
Version:
A simple terminal snake game library with no external dependencies
53 lines (39 loc) • 1.11 kB
Markdown
# Terminal Snake Game
A simple terminal snake game library with no external dependencies.
## Installation
```bash
# Install globally
npm install -g terminal-snake-game
# Or install locally
npm install terminal-snake-game
```
## Usage
### Global Installation
After installing globally, you can start the game directly:
```bash
snake-game
```
### Local Installation
You can use it in your code:
```javascript
const { startGame } = require('terminal-snake-game');
// Start the game
startGame({
width: 20, // Game area width
height: 10, // Game area height
speed: 200 // Game speed (milliseconds)
});
```
## Controls
- Use arrow keys (↑↓←→) to control the snake
- Press 'q' to quit the game
- Press 'r' to restart the game
## Game Rules
1. Control the snake to eat food (*) to grow longer
2. Game ends if the snake hits the wall or itself
3. Score 10 points for each food eaten
## Features
- Pure JavaScript implementation, no external dependencies
- Customizable game area size
- Customizable game speed
- Real-time score display