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

minojs

v0.3.0-beta

Published

Javascript block game library

Downloads

13

Readme

MinoJS

MinoJS is a lightweight javascript library for building block-stacking games such as Tetris. MinoJS provides a layer of abstraction around core game logic, and your app handles graphics/UI updates based on the emitted events. Implement one of the game modes that are ready use, or extend MinoCore/TetraCore to handle your own timing and scoring logic without starting from the ground up.

Reference Hard Drop's glossary of Tetris jargon for terms used in this doc

Installation

npm install minojs

MinoCore

MinoCore maintains the game state and implements base functionality that should be applicable to most games. When you call a function to request some action, it will return a list of resulting events. MinoCore handles:

  • Playfield, next preview, and hold queue state management
  • Generating UI-friendly grid arrays
  • Piece queuing, spawning, "Random Generator" (ie 7-bag randomization)
  • Piece movement: left/right shifting, collisions, dropping and locking, hard drops, support logic for rotation implementations
  • Clearing lines
  • Ghost/shadow piece tracking
  • Game end detection: Block out and lock out
  • Coming soon: Finesse
  • Configurations available: number of rows/columns on the playfield, size of next preview, piece shapes, and randomization method (see core/core.json for the defaults)

TetraCore

Extension of MinoCore.js meant for games which use 4-block tetrominos, such as Tetris. Here's what TetraCore handles:

  • All features from MinoCore.js
  • SRS rotation
  • Coming soon: T-spin detection
  • Configurations available: Rotation offsets for SRS (see core/core.json for the defaults)

Game modes

Complete game classes which are built around TetraCore and handle user input processing and game timing. They also handle:

  • Implementing DAS, ARR, auto-dropping, hard/soft drops, etc.
  • Reporting statistics/game info including formatted game time, PPS, KPP, cleared lines, number of blocks dropped, etc.
  • Configurations available for all modes (all lintervals and delays are in milliseconds): DAS, ARR, game clock interval, drop interval, drop lock delay, max allowed active time, soft drop interval, DAS-preservation enabled, DAS-interuption enabled, and scoring point values. See modes/modes.json for the defaults)

Sandbox

MinoJS includes a barebones implementation of TetraminoGame.js written in Svelte. It's used for developing/testing this library and could be a good resource. Here's how to run it.

git clone https://github.com/jspin-dev/minojs.git
cd minojs/sandbox
npm install
npm run dev

Tip: To set your preferred game settings and keybindings, modify sandbox/sandboxLocal.json