The pack
topdown
function topdown(opts: TopdownOptions = {}): Pack<{ world: World2dApi }>
The top-down world pack: within a layer, things sort by their FEET (y + half the scaled height + z), so the player walks behind the tree. Installs the 2D camera; registers the world with the kernel.
Types
TopdownOptions
interface TopdownOptions
Manifest options.
layers?: LayerName[]— Draw layers, back to front. Default ['floor', 'world', 'fx'].wrap?: Wrap— A toroidal world of this size (world units): positions, drawing, camera, queries and collision all wrap. Game code never wraps a coordinate. Default none.
World2dApi
interface World2dApi
game.world for either 2D world kind.
readonly kind: 'topdown' | 'side'— Which 2D world this is.readonly layers: ReadonlyArray<LayerName>— The layer names, back to front. Spawning into any other name throws.toWorld(sx: number, sy: number): { x: number; y: number }— Screen (logical pixels) to world, through the camera.toScreen(wx: number, wy: number): { x: number; y: number }— World to screen (logical pixels), through the camera.readonly wrap: Wrap | null— The wrap size, or null. Read it for spawning at the edges; never wrap a coordinate yourself.readonly view: { x: number; y: number; w: number; h: number; cx: number; cy: number }— What the camera is looking at right now, in world units. Derived every read, so it is never a frame behind.vw(f: number): number— The world x a fraction across the view: 0 the left edge, 1 the right. Camera-aware, sovw(0.5)is always the middle of the screen.vh(f: number): number— The world y a fraction down the view: 0 the top, 1 the bottom.


