API Reference
Complete API documentation generated from source code.
Version 0.1.0 · 75 exports · Generated 1/28/2026
Classes(2)
GlyftError
renderer.ts:8Custom error class for Glyft with fix instructions.
TweenManager
tween.ts:72Tween manager with object pooling.
Interfaces(28)
AnimationDef
types.ts:258Named animation definition for override animations
Atlas
types.ts:690Texture atlas
AtlasFrame
types.ts:706Atlas frame data
Camera
types.ts:745Camera
CollisionAction
types.ts:293Collision action
FloatTextOptions
types.ts:273Options for floating text
Glyft
types.ts:813Main Glyft engine interface
GlyftAddon
types.ts:198A 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:353Main 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:48Core engine settings - required for every Glyft game.
Example
Input
types.ts:766Input manager
NetworkAdapter
types.ts:799Network adapter interface
NetworkAdapter
network.ts:21Network adapter interface. Implement this for your transport layer (WebSocket, socket.io, WebRTC, etc.)
Example
NetworkConfig
types.ts:342Network configuration
NetworkConfig
network.ts:56Network configuration for GlyftConfig.
ParticleEmitterDef
types.ts:311Particle emitter definition
SfxDef
types.ts:121Declarative 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:22Compiled shader program
SoundRule
types.ts:165Sound rule options
Sprite
types.ts:464A 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:444Pointer event fired on interactive sprites or the game canvas.
StatDef
types.ts:114Stat definition
Stats
types.ts:778Stats manager
TileMap
types.ts:714Tilemap
TweenHandle
tween.ts:64Tween handle for cancellation
TweenOptions
tween.ts:37Tween configuration options
TweenProps
tween.ts:28Properties that can be tweened
TweenTarget
tween.ts:45Any object with numeric properties that can be tweened
Types(11)
Direction
types.ts:458Direction (for 4dir mode)
Direction8
types.ts:461Direction (for 8dir mode)
EaseFn
tween.ts:22Easing function type
EaseName
tween.ts:25Easing name (matches helpers.ts)
FloatTextAction
types.ts:287Config for floatText in collision actions: true = auto, or override options
FloatTextStyle
types.ts:270Float text display style
GameEvent
types.ts:787Game event for network sync
GameEvent
network.ts:7Game events sent between client and server.
Handler
types.ts:339Custom handler function
LabelVisible
types.ts:290Label visibility mode
SpriteMode
types.ts:13Sprite 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:132Get the angle from one point to another (in radians).
Example
applyCollisionAction
collision.ts:189Apply 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:52Clamp a value between min and max.
Example
compileShader
renderer.ts:90Compile a shader program from vertex and fragment source.
createBuffer
renderer.ts:357Create a vertex buffer.
createCollisionSystem
collision.ts:45Create collision system.
createContext
renderer.ts:29Initialize WebGL2 context with optimal settings.
Example
createDataTexture
renderer.ts:310Create a data texture (for tilemap storage).
createMusicManager
music.ts:78Create the music manager.
createSoundManager
sounds.ts:39Create the sound manager.
createVAO
renderer.ts:374Create a VAO for instanced rendering.
distance
helpers.ts:70Calculate Euclidean distance between two points.
Example
distanceSquared
helpers.ts:91Calculate squared distance (faster than distance, good for comparisons).
Example
findMatchingRule
sounds.ts:407Find the best matching rule for a collision/event. More specific patterns take priority.
getDirection4
helpers.ts:380Calculate direction index from velocity (for 4-direction sprites).
Example
getDirection8
helpers.ts:403Calculate direction index from velocity (for 8-direction sprites).
lerp
helpers.ts:31Linear interpolation between two values.
Example
loadTexture
renderer.ts:240Load an image and create a WebGL texture.
Example
matchesPattern
sounds.ts:345Pattern 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:421Move a value toward a target at a constant speed.
Example
normalize
helpers.ts:112Normalize a 2D vector (make it unit length).
Example
pointInRect
helpers.ts:442Check if a point is inside a rectangle.
randomBetween
helpers.ts:175Generate a random number between min and max (inclusive).
Example
randomInt
helpers.ts:192Generate a random integer between min and max (inclusive).
Example
randomPick
helpers.ts:209Pick a random element from an array.
Example
rectsOverlap
helpers.ts:464Check if two rectangles overlap.
resizeCanvas
renderer.ts:385Set canvas size to virtual viewport (pixel-perfect). CSS handles scaling - canvas stays at exact viewport size.
shuffle
helpers.ts:226Shuffle an array in place (Fisher-Yates algorithm).
Example
smoothDamp
helpers.ts:509Smoothly damp a value toward a target (spring-like smoothing).
Example
toDegrees
helpers.ts:161Convert radians to degrees.
toRadians
helpers.ts:151Convert degrees to radians.
updateDataTexture
renderer.ts:341Update a region of a data texture.
wrap
helpers.ts:490Wrap a value around a range (useful for seamless map scrolling).
Example
Constants(1)
easing
helpers.ts:249Easing 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