Skip to content

@studiokeywi/banjo🔗

The fast and plucky game framework from studioKeywi 🪕 Zero dependencies 🪕 Tree shakeable exports 🪕 Built with ❤️, Bun, and TypeScript.

These docs are powered by Material for MkDocs and TypeDoc

NPM Version NPM Type Definitions NPM Unpacked Size NPM License

@studiokeywi/banjo is a TypeScript game framework meant to be run in the browser or a similar web view (such as through Electron or Tauri) through the build process of your choice. Although dependency free, Banjo expects to have access to browser-provided functionality such as the cancelAnimationFrame/requestAnimationFrame functions, the HTMLImageElement/Image objects, and the <canvas> element. If you can provide these where your code will run, then Banjo should run there as well!

  • 🚫 Dependency Free
    studioKeywi wants you to have confidence that the code we provide doesn't rely on outside vectors. We may not be the best choice, but we believe we are a transparent choice when it comes to understanding our functionality.
  • 🌳 Tree Shakeable Exports
    Banjo exposes all of its functionality through its exports map, separated out by concern. That way, you can be sure that your games only contain the minimum code required for your final product.
  • ⚡ Powered by Bun and TypeScript
    Bun provides our development cycle with speed and built-in functionality that reduces our development load.
    TypeScript provides our users with a better development experience and flexibility in their build patterns.

Installation🔗

Banjo is published to the NPMJS registry and can be installed with any compatible package manager. Depending on your build process, you may be able to install as a development dependency instead.

bun add @studiokeywi/banjo
# or
bun add -D @studiokeywi/banjo
deno add npm:@studiokeywi/banjo
# or
deno add -D npm:@studiokeywi/banjo
npm install @studiokeywi/banjo
# or
npm install -D @studiokeywi/banjo

Quick Start🔗

Check out the quick start in the examples section of the docs for a project that demonstrates Banjo in under 125 lines of code

Features🔗

Banjo provides exports across a wide variety of concerns. ⚠️ indicates an undeveloped/unfinished feature. 📋 indicates incomplete documentation:

bootstrap 📋

Utilities to be run as part of a loading process, such as detecting the expected monitor refresh rate or loading audio/visual assets

API Docs

chrono

A helper format to make it easier to translate different resolutions of time (such as milliseconds, minutes, and days) across Banjo functions

API Docs

emitter

A wrapper around the native EventTarget that provides the more modern emit/off/on/once API over addEventListener/dispatchEvent/removeEventListener as well as improved IntelliSense

API Docs

engine

The core "game engine" in terms of responsibility. Features an emitter that can be used across game concerns, a loop that executes provided code, and an input/keyboard handler

API Docs

fsm 📋

General purpose finite state machine pattern

API Docs

hof

General purpose higher-order functions such as debounce and throttle

API Docs

index

Information about banjo itself

API Docs

input/controller 📋

Event handling for generic game controllers

API Docs

input/keyboard

Event handling for keyboards

API Docs

input/keys

Constant values related to keyboard events and utility functions to help with "meta" state for keyboard events

API Docs

input/mouse 📋

Event handling for mice

API Docs

loop

A rate-limited loop pattern. Designed to execute an "update" function at a provided tick rate, and a "render" function at the user's monitor's refresh rate

API Docs

math/constants

Frequently used mathematic constants, usually related to circular values such as fractions/multiples of tau and conversions between radians and degrees

API Docs

math/conversions

Functions to convert numeric values, such as circular conversions or value clamping

API Docs

math/easing

Easing or shaping functions that modify values between [0-1] in predictable ways

API Docs

math/geometry

2D convex polygonal/circular representations and utilities for detecting and calculating various intersections and overlaps

API Docs

math/m3 📋

3D matrix math utilities

API Docs

math/m4 📋

4D matrix math utilities

API Docs

math/random

Simple API wrapping around arbitrary pseudo-random number generation algorithms and their common utilizations (such as random integers and shuffling arrays)

API Docs

math/v2

2D vector math utilities

API Docs

math/v3 📋

3D vector math utilities

API Docs

pool

A utility for creating object pools that utilizes the proposed explicit resource management API to clear and restore objects to the pool when unused

API Docs

rendering/canvas 📋

Utilities for working with <canvas>, OffscreenCanvas, and web workers

API Docs

rendering/webgl 📋

Utilities for working with WebGL2RenderingContext

API Docs

ringArray

A generator-wrapped view into an array that allows jumping and infinite stepping through its contents, as well as basic array-like functions such as insertion, removal, and viewing at an index

API Docs

timing

Utilities for viewing performance timeline entries during selected time periods

API Docs

types

General utility types for internal and external use

API Docs

watcher

Configurable object that can manage executing functions under a variety of logical and/or timing constraints

API Docs