API Reference

Complete API documentation generated from source code.

Version 0.1.0 · 75 exports · Generated 1/28/2026

Classes(2)

GlyftError

renderer.ts:8

Custom error class for Glyft with fix instructions.

TweenManager

tween.ts:72

Tween manager with object pooling.

Interfaces(28)

AnimationDef

types.ts:258

Named animation definition for override animations

Atlas

types.ts:690

Texture atlas

AtlasFrame

types.ts:706

Atlas frame data

Camera

types.ts:745

Camera

CollisionAction

types.ts:293

Collision action

FloatTextOptions

types.ts:273

Options for floating text

Glyft

types.ts:813

Main Glyft engine interface

GlyftAddon

types.ts:198

A Glyft addon extends the engine with new capabilities via `game.use()`. Lifecycle: 1. Factory function creates addon config → GlyftAddon object 2. `game.use(addon)` calls `init()` with the game instance 3. Each frame, hooks are called in order: - `preUpdate(dt)` → before user `onUpdate` callbacks - `postUpdate(dt)` → after user callbacks, before collision detection - `postPhysics(dt)` → after collisions + reactive sounds 4. `destroy()` called on addon removal

GlyftConfig

types.ts:353

Main configuration object for a Glyft game. Glyft is config-driven: game rules are defined as data, not scattered code. This enables hot-reload, easy serialization, and cleaner game logic.

Example

GlyftSettings

types.ts:48

Core engine settings - required for every Glyft game.

Example

Input

types.ts:766

Input manager

NetworkAdapter

types.ts:799

Network adapter interface

NetworkAdapter

network.ts:21

Network adapter interface. Implement this for your transport layer (WebSocket, socket.io, WebRTC, etc.)

Example

NetworkConfig

types.ts:342

Network configuration

NetworkConfig

network.ts:56

Network configuration for GlyftConfig.

ParticleEmitterDef

types.ts:311

Particle emitter definition

SfxDef

types.ts:121

Declarative sound effect definition. Each SfxDef describes a procedurally-generated sound using Web Audio oscillators. All fields are serializable JSON — no callbacks, no audio files needed.

Example

ShaderProgram

renderer.ts:22

Compiled shader program

SoundRule

types.ts:165

Sound rule options

Sprite

types.ts:464

A game sprite with GPU-driven animation. Sprites use velocity-driven animation: set `vx` and `vy`, and the GPU shader automatically selects the correct direction and walk/idle frames.

Example

SpritePointerEvent

types.ts:444

Pointer event fired on interactive sprites or the game canvas.

StatDef

types.ts:114

Stat definition

Stats

types.ts:778

Stats manager

TileMap

types.ts:714

Tilemap

TweenHandle

tween.ts:64

Tween handle for cancellation

TweenOptions

tween.ts:37

Tween configuration options

TweenProps

tween.ts:28

Properties that can be tweened

TweenTarget

tween.ts:45

Any object with numeric properties that can be tweened

Types(11)

Direction

types.ts:458

Direction (for 4dir mode)

Direction8

types.ts:461

Direction (for 8dir mode)

EaseFn

tween.ts:22

Easing function type

EaseName

tween.ts:25

Easing name (matches helpers.ts)

FloatTextAction

types.ts:287

Config for floatText in collision actions: true = auto, or override options

FloatTextStyle

types.ts:270

Float text display style

GameEvent

types.ts:787

Game event for network sync

GameEvent

network.ts:7

Game events sent between client and server.

Handler

types.ts:339

Custom handler function

LabelVisible

types.ts:290

Label visibility mode

SpriteMode

types.ts:13

Sprite animation mode - determines how velocity maps to sprite directions. The mode you choose affects how your spritesheet should be organized: | Mode | Rows | Description | |------|------|-------------| | `'4dir'` | 4 | Down, Right, Up, Left (RPG-style) | | `'8dir'` | 8 | 8 compass directions | | `'2dir-side'` | 1 | Left/Right, GPU flips for left (platformer) | | `'2dir-top'` | 2 | Down, Up only | | `'1dir'` | 1 | Single direction, use rotation for facing | | `'iso4'` | 4 | Isometric SE, SW, NW, NE | | `'iso8'` | 8 | 8 isometric directions |

Example

Functions(33)

angleTo

helpers.ts:132

Get the angle from one point to another (in radians).

Example

applyCollisionAction

collision.ts:189

Apply collision action for pattern [A]:[B] — "A encounters B". Effects (damage, heal, knockback, flash) target A (the subject). Removal (destroy, collect) targets B (the thing encountered). Float text appears above A.

clamp

helpers.ts:52

Clamp a value between min and max.

Example

compileShader

renderer.ts:90

Compile a shader program from vertex and fragment source.

createBuffer

renderer.ts:357

Create a vertex buffer.

createCollisionSystem

collision.ts:45

Create collision system.

createContext

renderer.ts:29

Initialize WebGL2 context with optimal settings.

Example

createDataTexture

renderer.ts:310

Create a data texture (for tilemap storage).

createMusicManager

music.ts:78

Create the music manager.

createSoundManager

sounds.ts:39

Create the sound manager.

createVAO

renderer.ts:374

Create a VAO for instanced rendering.

distance

helpers.ts:70

Calculate Euclidean distance between two points.

Example

distanceSquared

helpers.ts:91

Calculate squared distance (faster than distance, good for comparisons).

Example

findMatchingRule

sounds.ts:407

Find the best matching rule for a collision/event. More specific patterns take priority.

getDirection4

helpers.ts:380

Calculate direction index from velocity (for 4-direction sprites).

Example

getDirection8

helpers.ts:403

Calculate direction index from velocity (for 8-direction sprites).

lerp

helpers.ts:31

Linear interpolation between two values.

Example

loadTexture

renderer.ts:240

Load an image and create a WebGL texture.

Example

matchesPattern

sounds.ts:345

Pattern matching for reactive sounds. Patterns: - `[tag]` - sprite has tag - `name*` - wildcard - `[t1,t2]` - multiple tags (AND) - `a:b` - a collides with b - `a:moving` - a has velocity - `a:destroyed` - a was destroyed

moveToward

helpers.ts:421

Move a value toward a target at a constant speed.

Example

normalize

helpers.ts:112

Normalize a 2D vector (make it unit length).

Example

pointInRect

helpers.ts:442

Check if a point is inside a rectangle.

randomBetween

helpers.ts:175

Generate a random number between min and max (inclusive).

Example

randomInt

helpers.ts:192

Generate a random integer between min and max (inclusive).

Example

randomPick

helpers.ts:209

Pick a random element from an array.

Example

rectsOverlap

helpers.ts:464

Check if two rectangles overlap.

resizeCanvas

renderer.ts:385

Set canvas size to virtual viewport (pixel-perfect). CSS handles scaling - canvas stays at exact viewport size.

shuffle

helpers.ts:226

Shuffle an array in place (Fisher-Yates algorithm).

Example

smoothDamp

helpers.ts:509

Smoothly damp a value toward a target (spring-like smoothing).

Example

toDegrees

helpers.ts:161

Convert radians to degrees.

toRadians

helpers.ts:151

Convert degrees to radians.

updateDataTexture

renderer.ts:341

Update a region of a data texture.

wrap

helpers.ts:490

Wrap a value around a range (useful for seamless map scrolling).

Example

Constants(1)

easing

helpers.ts:249

Easing functions for smooth animations. All functions take t in range [0, 1] and return value in range [0, 1].

Example

Generated from source code · Run npm run generate-docs to update