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

crisp-game-lib

v1.2.0

Published

Minimal JavaScript library for creating classic arcade-like mini-games running in the browser

Downloads

1,956

Readme

crisp-game-lib

English | 日本語

crisp-game-lib is a JavaScript library for creating browser games quickly and easily.

Getting started

  1. Download docs/getting_started/index.html.

  2. Open index.html in a text editor and write the code of your game in the <script> element.

  3. Open index.html in a browser and play the game.

  4. You can publish the game by putting index.html on your web server.

Write your own game (with the help of IntelliSense and Live Reload)

  1. Clone or download this repository.

  2. npm install

  3. Copy the docs/_template directory and rename it to docs/[your own game name].

  4. Open docs/[your own game name]/main.js with the editor (VSCode is recommended) and write your own game code.

  5. npm run watch_games

  6. Open the URL http://localhost:4000?[your own game name] with a browser to play the game. The page is live-reloaded when the code is rewritten.

Publish your own game

  1. Place main.js, docs/bundle.js, and docs/index.html on the webserver in the following directory structure.

    ┝ [games root directory (any name)]
       ┝ [your own game name]
       │  └ main.js
       ┝ bundle.js
       └ index.html
  2. Open the URL [Address of games root directory]/index.html?[your own game name] with a browser.

Use with a bundler

If you want to build a game using a bundler (e.g. Vite), do the following.

  1. npm install crisp-game-lib at your project directory.

  2. Copy docs/_template_bundler/index.html and docs/_template_bundler/main.js to your project directory.

  3. Write game code in main.js.

  4. Build with the bundler.

If you want to describe the game using TypeScript, rename main.js to main.ts.

Function introduction demo

Drawing / Collision / Input / Audio

Related articles

Tips

  • By drawing with color("transparent"), you can get the result of collision detection without drawing any shape on the screen.
  • The collision detection is based on the drawing history of the shape. Therefore, even if a drawn shape is overwritten with a background-colored shape, the collision detection in that area will not disappear.
  • The base value for the random seed for sound generation is generated from the title and description strings. If you want to use seed in options to adjust the generated sound, it is better to do so after the title and description are fixed.
  • To improve the performance of the game, do the following (mainly for mobile devices):
    • Use simple or dark theme. Do not specify a theme that uses pixi.js (pixel, shape, shapeDark, crt) in options. WebGL post-effects may worsen performance.
    • Minimize drawing bars, lines, or arcs. They are drawn as a combination of many rectangles and are highly detrimental to the collision detection process.
  • If you want to create a game that can be played comfortably on a mobile device, I recommend that you adopt one of the following three control methods.
    • One-button
    • Slide operation left or right direction only
    • Tapping on a specific place on the screen
  • For more information on how to create a one-button game, please refer to the following article I wrote: How to realize various actions in a one-button game
  • The sounds-some-sounds library can be used to play music. To play music written in MML, use the sss.playMml() function.
  • If you want to run crisp-game-lib games on small devices such as M5Stack or Adafruit PyBadge, you can use the C implementation version crisp-game-lib-portable.