A simple terminal snake game library with no external dependencies.
# Install globally
npm install -g terminal-snake-game
# Or install locally
npm install terminal-snake-game
After installing globally, you can start the game directly:
snake-game
You can use it in your code:
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)
});
- Use arrow keys (↑↓←→) to control the snake
- Press 'q' to quit the game
- Press 'r' to restart the game
- Control the snake to eat food (*) to grow longer
- Game ends if the snake hits the wall or itself
- Score 10 points for each food eaten
- Pure JavaScript implementation, no external dependencies
- Customizable game area size
- Customizable game speed
- Real-time score display