Optional world boundaries / bounds (keep entities in a play area) #84
Labels
No labels
area:ci
area:docs
area:input
area:net
area:rendering
area:repo
area:stdlib
area:tooling
area:types
cleanup
dx
priority:high
priority:low
priority:medium
proposal
status:in-progress
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference: workshopsoft/ludic#84
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
There is no built-in world boundary. Games hand-roll clamping (clamp Position each frame) to fake walls / keep entities inside a play area.
Proposal: an optional world-bounds feature — a bounds rect/config (per-world or per-scene) with a policy (clamp / wrap / bounce / kill-on-exit), applied by the move system when enabled. Off by default (open world). Seen: an external game clamps Body entities manually.
Shipped in
ad3be0c(full suite 112/0, goldens byte-identical, fixpoint intact).Declare a single
Boundsconfig entity (a rectx, y, w, h+ a policy, shipped from ludic.core) and the engine-owned world-bounds system keeps every movingBodyinside the play area each frame — no more hand-clampingPosition. Four policies:0clamp — stop at the edge (walls)1wrap — reappear on the opposite side (toroidal)2bounce — clamp and flip the Body velocity on the axis that hit3kill — despawn a body fully outside (offscreen cleanup)It reads each body's
Collidersize so the whole box stays inside. Off by default (no Bounds entity = open world), registered on the engine-system registry for LateUpdate (after movement integrates), and spliced only when a game declaresBounds, so a game that never does compiles byte-identically.Also adds
World.despawn(entity)— the reflective, by-id form of thedespawnstatement (runs@OnDespawn+ frees the slot), which the kill policy uses and any system can call; its@fn_world_despawnhelper is emitted in the codegen tail once a use is seen (the sameg_uses_*-prelude pattern the string/net helpers use), so non-users are byte-identical.Verified by
examples/library/world_bounds.ludic— clamp (stops at the wall, 184), wrap (-16), bounce (clamped + velocity flipped), kill (body fully outside removed): prints184 -16 184 1 0. Docs page for World.despawn added.