Overview & Quick Start
Maverick Game Engine is a pure TypeScript 2D and isometric 2.5D browser canvas game engine. Zero React or UI framework lock-in—just strongly-typed OOP classes, deterministic fixed-step simulation, and HTML5 Canvas 2D.
1. Install
npm install maverick
2. Your First Game
Every game subclasses Game and implements lifecycle hooks:
onReady(), onUpdate(timeDelta), onDraw(timeDelta, perf), and onDisengaged().
import { Game, type SystemPerformance } from 'maverick';
class HelloGame extends Game {
onReady(): void {
this.Logger.info('Game ready!');
}
onDisengaged(): void {
this.Logger.info('Cleaned up!');
}
onUpdate(_timeDelta: number): void {
// Fixed-step simulation logic (in seconds)
}
onDraw(_timeDelta: number, perf: SystemPerformance): void {
this.Viewport.clear();
this.Viewport.drawText(
`Hello Maverick (${perf.fps} FPS)`,
{ x: 24, y: 32 },
this.Fonts.get('default')
);
}
}
const root = document.getElementById('game-root');
if (root) {
const game = new HelloGame({
name: 'HelloWorld',
viewport: { width: 480, height: 320, fps: 60, bgColor: '#0f172a', showPerfStats: true },
});
game.mount(root);
}
Lifecycle & Cleanup: Call
game.pause() to pause/unpause simulation,
or game.unmount() to stop the loop, release DOM listeners, and remove any auto-created canvas.
3. Core Managers on Game
| Property | Responsibility |
|---|---|
game.Viewport | Canvas 2D context, DPR scaling, Camera2D, drawing, wrapped text |
game.Elements | Flat GameElement registry (for single-scene games) |
game.Scenes | Multi-scene switching (SceneManager) |
game.Sprites | Image loading (preload) and spritesheet sub-rectangles |
game.Input | Action-mapped keyboard & mouse input |
game.UI | Retained in-canvas UI widgets (UIButton, UIPanel, etc.) |
game.Sounds | Web Audio buses (master, sfx, music) |
game.Timers / game.Tweens | Pause-aware timers and property tweening |