Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Game simulation and stories

These libraries run on the CPU. An application chooses a fixed timestep and owns the game world, input, renderer and save.

Quests

(snail shell game quest) exports define-quest. Supply the stage and event types and one row per transition. The generated function takes a stage and an ordered list of observations. It returns the result of the first applicable transition, or the original stage. Payloads bind in ordinary patterns, so a counted goal can carry its current count. A tick advances at most one stage. The application decides which observations the world supplies. Quest example · Source

Dialogue

(snail shell game dialogue) reads a Dialogue made of named passages, lines and ordered replies. Each reply names its destination. The game saves a Cursor containing the passage ID and line index. Import a baked Ink library or construct a dialogue directly. open-dialogue, continue-dialogue and answer-dialogue return an optional cursor. An out-of-range answer keeps the current cursor. Ink authoring · Source

Compiling Ink

(snail shell game ink) supplies ink-library for a generate-library recipe. Its first filename is the Ink entry point. Each additional filename links a source used by an INCLUDE. At build time the producer calls inklecate and returns a library exporting conversation as a Dialogue. Games import that generated library. make test-ink builds an independent project, edits its story and included knot, and exercises failed generations. Example recipe and Ink files · Source

Movement and boarding

(snail shell game terrain) reads a GRD1 contact mesh. ground-height evaluates the triangle under an XZ position, ground-slope samples a grade across a given span, and nearby-solids supplies local building and trunk footprints for a sweep. A cell index bounds the triangle search. Ground and kerbs support movement, while obstacles restrict it. Terrain file layout

(snail shell game physics) sweeps a disc through axis-aligned footprints, slides a walking body along a wall, and measures clear paths and shot distances. (snail shell game vehicle) integrates a rear-axle bicycle model and checks its rotated chassis extents. Coordinates are metres in the XZ plane. Heading zero faces north along −Z and positive angles turn east. Physics · Vehicle A caller keeps one DriverControls, advances it with adjust-driver! each tick, and passes its pedal and wheel to road-speed and road-steering. These functions model power-limited acceleration, braking, road grade and a shared longitudinal/lateral grip limit. bicycle-step integrates the resulting signed speed and steering angle.

(snail shell game rigid-body) gives each body a 3D centre, unit quaternion, world-space linear and angular momentum, inverse mass and body-space inverse inertia. Construct a box with box-body. Apply gravity with accelerate! and an impact with apply-impulse! at a world-space point. Rotate local spheres into world space with world-balls. Generate sphere-pair and plane contacts, pass them together to solve-contacts!, then advance every body with integrate!. Each solver sweep accumulates a normal impulse and bounds the tangential impulse by Coulomb friction. The caller chooses the step size and sweep count. Fast objects can cross thin geometry between discrete steps. Sequential impulses

(snail shell game chassis) puts these bodies on a road. road-chassis starts a car aligned with the measured grade. step-cars! applies pedal and steering inputs while the wheels have traction and solves the whole fleet against vehicle bodywork, the terrain and nearby solid footprints. Gravity and collisions can pitch, roll or overturn a car. Four tyre contacts, a compound sphere hull and a local ground plane approximate its shape and support. chassis-body projects the 3D state onto the street map for navigation and boarding.

The chassis solver also accepts walking people through walker-step and step-traffic!. A walking person stays under foot control until a moving chassis makes contact. The solver then integrates a finite-mass body against the cars, terrain and walls in the same substeps.

(snail shell game boarding) advances a saved Rider toward a driver or passenger door, across the sill and into the seat. The car’s placement determines both anchors. An approach uses the four expanded chassis corners to find a clear way around either end. The game holds the car while crossing? is true and may reposition it if a waiting rider’s door is blocked. rider-body and seat-weight locate the actor and blend the seated pose from the same progress. Source

Roads and local traffic

(snail shell game atlas) opens compressed map bands already read through Resources. An Area holds the current sector and its eight neighbours. Call focus-area! as the player moves. The area keeps one eighth of a sector as a margin across its centre’s edge so that a switchback can cross the seam without rebuilding twice. prepare-area! takes a forecast position and inflates at most one missing sector per call. When ready, it returns the candidate area in drawing order. The current area advances only through focus-area!, which reuses completed work and handles teleports immediately. Overlapping sectors keep their decoded contact data, mesh and signs. area-height, area-slope and area-solids query the same geometry the renderer uses.

(snail shell game roads) reads a directed junction and street-name table. road-route uses A* with straight-line distance as its lower bound. follow-edge places a body a given distance along an edge and a lateral distance from its centre. (snail shell game traffic) uses the outgoing edges for its drivers and chooses clear sidewalk segments for pedestrian patrols. replacement-motor checks the snapped lane position against the cab’s actual direction of travel, its stopping space and nearby bodies. It returns an option so a caller can keep an existing car when every candidate is unsuitable. The application supplies the nearby people and vehicles, traffic density and time step. Road graph

Following a moving body

(snail shell game chase) advances a camera focus in world space. Pass follow the previous Chase (or (None) for the first frame), a target position, heading in radians, elapsed seconds and initial boom length. The focus follows a critically damped spring, the heading takes the short arc, and a displacement of 24 metres or more resets the rig at the target. The caller places the camera using that focus and boom. Source

Actors and scenery

(snail shell game humanoid) blends idle, stride, upper-body action and riding clips on a generic rig. Distance walked advances stride. (snail shell game pedestrian) follows waypoints and resumes them after fleeing a nearby disturbance. Humanoid · Pedestrian

(snail shell game drawing) places rigid parts relative to a model. (snail shell game figure) assembles figures from these parts. (snail shell game scenery) places the same shapes into a glTF scene and builds matrices for moving them. Drawing · Figure · Scenery