@jpd.nz/snek
TypeScript icon, indicating that this package has built-in type declarations

1.1.3 • Public • Published

SNEK

A simple yet addictive JS rendition of the classic snake game.

Demo

Head on over to my website and enter the magic cough konami cough code... https://jpd.nz

Instalation

Using npm (or package manager of your choice):

  npm i @jpd.nz/snek

Usage

import Snek from '@jpd.nz/snek'

const snek = new Snek(
  { 
    gameElement: document.querySelector('#game'), // Required. Must provide a gameElement
    gameFont: { // Optional along with all props
      family: 'fontfamily',
      weight: 600,
      size: 30,
      color: '#FFFFFF'
    }
  }
)

// To start the game use the `init` function
snek.init()

// To listen to in game events
snek.on('reset', () => {
  console.log('re-re-re-reeeeset!')
})

snek.on('start', () => {
  console.log('ready... fight!')
})

snek.on('end', () => {
  console.log('gameover man, gameover!')
})

// To stop the game processes run the `destroy` function
snek.destroy()

Package Sidebar

Install

npm i @jpd.nz/snek

Weekly Downloads

0

Version

1.1.3

License

MIT

Unpacked Size

17.7 kB

Total Files

12

Last publish

Collaborators

  • prowsejeremy