by-sensors

16.9.9 • Public • Published

Terminal Snake Game

A simple terminal snake game library with no external dependencies.

Installation

# 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:

snake-game

Local Installation

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)
});

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

Package Sidebar

Install

npm i by-sensors

Weekly Downloads

1,003

Version

16.9.9

License

MIT

Unpacked Size

15.3 kB

Total Files

8

Last publish

Collaborators

  • gdshh