Package-level declarations

The engine surface in five parts: Game, the entry composable running the loop; the entity tier (PolygonEntity, a polygon-node subclass whose copy obligation every entity class discharges to carry its facts through the shape-preserving operations; GroupEntity, its group-node analog with typed children and a typed copy obligation); the world frame (World with its scene draw-order tree projection, the root the engine draws, and the per-step update hook) every game's state builds on, with FollowInputX as the stateful pointer-or-keys follow helper; the per-step context and snapshots (Step carrying the step's duration and its Input/Pointer/Keys sample, established as the context of every update, and restart, the step-gated call ending a step and the world it runs in through its Restart signal); and the load boundary (AssetScope) building every world — the first and each replacement — from SVG assets and programmatic shapes.

Types

Link copied to clipboard
class AssetScope(resources: suspend (String) -> ByteArray)

The load entry: SVG assets load through it, arriving as ready scene-graph values.

Link copied to clipboard
class Controls(val keys: Set<Key> = emptySet(), val pointer: FlatPoint? = null, val pointerDown: Boolean = false)

One step's commanded input, stated as level state only: which keys are held, and where the pointer is.

Link copied to clipboard
interface Entity

A thing in the game world with a position, read as x and y.

Link copied to clipboard
class FollowInputX(speed: Double, left: Key, right: Key)

Horizontal motion commanded by the player: the pointer's x is followed absolutely, and the key pair slides while the pointer rests.

Link copied to clipboard
abstract class GroupEntity<E : Node>(val children: List<E>, bounds: SceneBounds? = null) : GroupNode

The base of a game entity whose body is a group of nodes: a GroupNode subclass, so the entity is its sub-tree — the typed children in draw order — plus whatever facts the game class adds.

Link copied to clipboard
class Input

One step's input snapshot: every active pointer and the keyboard, handed to the game's step function — sampled state, never events.

Link copied to clipboard
class Keys

The keyboard snapshot, over Compose Key codes.

Link copied to clipboard
class Pointer

One pointer — a mouse or a touch contact — in CGA model units.

Link copied to clipboard
abstract class PolygonEntity(node: PolygonNode) : PolygonNode, Entity

The base of a game entity whose body is a polygon: a PolygonNode subclass, so the entity is its node — geometry, style, and tags — plus whatever facts the game class adds.

Link copied to clipboard

The signal that ends a step and the world it ran in: the world is discarded and a new one is built in its place.

Link copied to clipboard
class Step(val dt: Double, val input: Input)

One step of the simulation: the step's duration paired with the input sampled for it.

Link copied to clipboard
abstract class World(val bounds: SceneBounds)

The base of every game's state: the world owns its entities and nodes as plain properties, advances through update, and is drawn as root.

Functions

Link copied to clipboard
fun <W : World> drive(world: () -> W, seconds: Double, tickRate: Int = 120, onStep: (elapsed: Double, world: W) -> Unit = { _, _ -> }, controls: (elapsed: Double, world: W) -> Controls = { _, _ -> Controls.NONE }): W

Advances the world world builds through seconds seconds of fixed-rate steps, its input commanded by controls — a whole game session run headlessly.

Link copied to clipboard
inline fun <E : Node> GroupEntity<E>.forEach(action: (E) -> Unit)

Runs action on each child, in draw order.

Link copied to clipboard
@Composable
fun <W : World> Game(modifier: Modifier = Modifier, tickRate: Double = 120.0, maxFrameTime: Double = 0.25, world: suspend () -> W)

Runs a game: world builds the first World, then every display frame the loop advances it step by step through World.update and draws World.root on screen.

Link copied to clipboard
operator fun <E : Node> GroupEntity<E>.iterator(): Iterator<E>

Returns an iterator over the children, in draw order.

Link copied to clipboard
operator fun <G : GroupEntity<E>, E : Node> G.minus(child: E): G

GroupEntity - Node => GroupEntity
Returns this entity without child among its children — a child leaves the group by the group being rebuilt without it.

Link copied to clipboard
context(_: Step)
fun restart(): Nothing

Ends the step and the world it runs in: the world is discarded and a fresh one is built in its place, as at launch.

Link copied to clipboard
operator fun <G : GroupEntity<*>> G.times(versor: Versor): G

GroupEntity * Versor => GroupEntity
Returns this entity with versor's motion applied to every leaf in its sub-tree — the entity-narrowed form of the scene graph's GroupNode * Versor.