Skip to content

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

PackageImportDescription
Collisionquantum-forge/collisionAABB, circle, point collision with SpatialGrid
Audioquantum-forge/audioHowler.js wrapper for sounds and music
Particlesquantum-forge/particlesBurst, trail, and continuous particle effects
Animationquantum-forge/animationTweening with easing functions
Entitiesquantum-forge/entitiesEntity management with spatial queries
State Machinequantum-forge/state-machineFinite state machine
Timerquantum-forge/timerPause-aware game timers
Savequantum-forge/saveSave management with versioning
Scenesquantum-forge/scenesStack-based scene lifecycle
Operationsquantum-forge/operationsExtensible operation registry/executor pattern

Add packages interactively:

bash
npm run add-system

See Packages for usage examples and API Reference for full specs.

Powered by Quantum Forge