Snake-js
Play the famous snake game in your terminal.
Installation
npm install --save @marcster/snake-js
Usage
let Snake = require('@marcster/snake-js');
// Snake(board width, board height, callback on loop end, speed in ms)
let snake = new Snake(10, 10, () => {
let score = snake.score;
// parse score to string
snake.debug('' + score);
}, 200);
Options
- Width - width of game area (will be multiplied by 2 since snake emoji requires 2 characters in terminal)
- Height - height of game area
- callback - function called during each loop after
draw()
but before setTimeout
- speed - game speed in ms