npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

dbi-snake-game

v1.1.5

Published

An open source "Snake"-game implementation as pure JavaScript module.

Downloads

109

Readme

DBIsnake

An Implementation of the classic video-game "Snake" as a pure JavaScript Module published as an NPM-package. The game uses an HTML-Canvas to display it's content

Usage

  • Import it into your project
  • Create a new instance of the game. The constructor needs to be passed a parent DOM-element to attach the canvas to and an Object for configuration options
  • Start the game loop with the start() method
  • The listeners the game creates can be cleaned up after the game was terminated with the destroy() method
  • The status of the game can be checked anytime via the "status" variable (0=game was terminated, 1 = pre init, 2 = game in progress, 3 = Game Over)

Configuration

Configuration is done via the configuration object passed to the constructor. The configuration object may contain the following properties:

  • gridSize - specifies the amount of rows and columns to use for the playing field
  • bgColor - sets the background color of the playing field
  • initSpeed - sets how fast the snake moves at the beginning of the game
  • speedUp - how the snakes speed should change any time it eats food. 1.1 equals to a 10% speedup
  • speedLimit - the minimum tick rate for the snakes movement
  • headColor- - color to use for the snakes head
  • config.bodyColor - color to use as the snakes body
  • config.initLength - how long the snake should be at the start of the game. This length does not count towards the score