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

kaboomware

v0.1.6

Published

![logo](logo.png)

Downloads

30

Readme

logo

KaboomWare is a tool for making warioware-like mini games in Kaboom.

Developing a Mini Game

A KaboomWare game is just a plain JavaScript object:

const squeezeGame = {

    // The prompt for the game that tells player what to do. Normally it'll be just a simple verb.
    prompt: "Squeeze!",

    // Name of the author.
    author: "tga",

    // Background color hue (0.0 - 1.0).
    hue: 0.46,

    // Load assets for the game. The argument k is a limited version of the Kaboom context, only k.loadXXX() functions are enabled here.
    onLoad: (k) => {
        k.loadSound("fly", "sounds/fly.mp3")
        k.loadSprite("hand", "sprites/hand.png")
    },

    // Main entry point of the game. This function should return a GameObject that contains the game. The argument k is a limited version of the Kaboom context, plus a set of KaboomWare-specific APIs (see below)
    onStart: (k) => {

        // k.add() is disabled, use k.make() to make a game object and return
        const scene = k.make()

        // All game objects are added as children of the scene game object
        const hand = scene.add([
            k.pos(420, 240),
            k.sprite("hand"),
        ])

        // KaboomWare only supports 1 action button and 4 directional buttons. Use the KaboomWare-specific API k.onButtonXXX()
        k.onButtonPress("action", () => {
            hand.squeeze()
            if (gotIt) {
                // Tell KaboomWare player has succeeded and progress to the next game
                k.win()
            }
        })

        // Return the scene game object here and it'll get mounted to KaboomWare when this game starts.
        return scene

    },

}

The added API in onStart() is

type GameAPI = {
    // Register an event that runs once when a button is pressed.
    onButtonPress: (btn: Button, action: () => void) => EventController,
    // Register an event that runs once when a button is released.
    onButtonRelease: (btn: Button, action: () => void) => EventController,
    // Register an event that runs every frame when a button is held down.
    onButtonDown: (btn: Button, action: () => void) => EventController,
    // Register an event that runs once when timer runs out.
    onTimeout: (action: () => void) => EventController,
    // Register an event that runs once when game ends, either succeeded, failed or timed out.
    onEnd: (action: () => void) => EventController,
    // Run this when player succeeded in completing the game.
    win: () => void,
    // Run this when player failed.
    lose: () => void,
    // Current difficulty.
    difficulty: 0 | 1 | 2,
}

type Button =
    | "action"
    | "left"
    | "right"
    | "up"
    | "down"

To run the game, use the kaboomware pacakge

import run from "kaboomware"

run([
    squeezeGame,
], {
    // Dev mode disables the timer, so you can focus on working on the current game
    dev: true,
    // Scale of the canvas
    scale: 1,
})

For real world examples, check here.

To run the examples:

$ git clone https://github.com/slmjkdbtl/kaboomware
$ cd kaboomware
$ npm install
$ npm run dev
$ open http://localhost:8000

Also try the Replit template

Caveats

Publishing a Mini Game

TODO