Framework Tools
Beyond quantum mechanics, the framework provides tools for building complete games: state management, rendering, input handling, and optional packages for audio, collision, particles, and more.
Engine
The Engine<TState> base class manages game state. You extend it and expose state-mutating functions via getHelpers():
typescript
import { Engine } from "quantum-forge/engine";
class MyEngine extends Engine<GameState> {
constructor(logger?: any) {
super({ score: 0, player: { x: 0, y: 0 } }, { logger });
}
getHelpers() {
return {
movePlayer: (dx: number, dy: number) => {
const state = this.getState();
state.player.x += dx;
state.player.y += dy;
this.setState({ ...state });
},
};
}
}See Engine for details.
Rendering
Two renderers are available:
PixiRenderer: WebGL/WebGPU via PixiJS 8 (recommended for new games)CanvasRenderer: Canvas 2D for simpler use cases
Plus GameLoop for the update/render cycle and Camera for world-space transforms.
typescript
import { PixiRenderer, GameLoop } from "quantum-forge/rendering";
class MyRenderer extends PixiRenderer {
protected draw(state: GameState) {
this.graphics.circle(state.player.x, state.player.y, 10).fill("#fff");
}
}
const renderer = new MyRenderer({ canvas, backgroundColor: 0x000000, logger });
await renderer.init();
const loop = new GameLoop({
update: (dt) => { /* game logic */ },
render: () => renderer.render(engine.getState()),
targetFps: 60,
logger,
});
loop.start();See Rendering for details.
Input
InputManager provides a unified binding system across keyboard, mouse, gamepad, and touch:
typescript
import { InputManager, GamepadButtons } from "quantum-forge/input";
const input = new InputManager({ logger });
input.bind("jump",
{ type: "key", code: "Space" },
{ type: "gamepad-button", index: GamepadButtons.A },
);
// In game loop:
input.poll();
if (input.isActionDown("jump")) { /* ... */ }Supports touch zones, virtual joysticks, gestures, and local multiplayer. See Input for details.
Optional Packages
| Package | Import | Description |
|---|---|---|
| Collision | quantum-forge/collision | AABB, circle, point collision with SpatialGrid |
| Audio | quantum-forge/audio | Howler.js wrapper for sounds and music |
| Particles | quantum-forge/particles | Burst, trail, and continuous particle effects |
| Animation | quantum-forge/animation | Tweening with easing functions |
| Entities | quantum-forge/entities | Entity management with spatial queries |
| State Machine | quantum-forge/state-machine | Finite state machine |
| Timer | quantum-forge/timer | Pause-aware game timers |
| Save | quantum-forge/save | Save management with versioning |
| Scenes | quantum-forge/scenes | Stack-based scene lifecycle |
| Operations | quantum-forge/operations | Extensible operation registry/executor pattern |
Add packages interactively:
bash
npm run add-systemSee Packages for usage examples and API Reference for full specs.