aboutsummaryrefslogtreecommitdiff
path: root/docs/entities.org
diff options
context:
space:
mode:
authorGene Pasquet <dev@etenil.net>2026-04-08 01:57:20 +0100
committerGene Pasquet <dev@etenil.net>2026-04-08 01:57:20 +0100
commit9e8b75f9949259ef01942cd3717b79b044efddf7 (patch)
treec6b71291ade57f0560a9bbf0db9f5b66bab65cb3 /docs/entities.org
parent84840ede6646ed793b61cdd889d3f57ab05e9311 (diff)
Refactor update pipelines
Diffstat (limited to 'docs/entities.org')
-rw-r--r--docs/entities.org18
1 files changed, 9 insertions, 9 deletions
diff --git a/docs/entities.org b/docs/entities.org
index 3766522..9f8e9ee 100644
--- a/docs/entities.org
+++ b/docs/entities.org
@@ -20,7 +20,7 @@ This minimal approach keeps the engine lean: your game defines whatever keys it
* Pipeline skips (~#:skip-pipelines~)
-The optional key ~#:skip-pipelines~ holds a list of **symbols** naming frame pipeline steps that should be skipped for that entity. The physics module defines the built-in step names (see ~docs/physics.org~). The predicate ~entity-skips-pipeline?~ and the syntax ~define-pipeline~ live in ~downstroke-entity~ so any subsystem (physics now; rendering or animation later if you extend the engine) can use the same mechanism without a separate “core pipeline” module.
+The optional key ~#:skip-pipelines~ holds a list of **symbols** naming frame pipeline steps that should be skipped for that entity. The physics module defines the built-in step names (see ~docs/physics.org~). The predicate ~entity-skips-pipeline?~ and the syntax ~define-pipeline~ (with optional ~guard:~ clause per step) live in ~downstroke-entity~ so any subsystem (physics now; rendering or animation later if you extend the engine) can use the same mechanism without a separate “core pipeline” module.
* Creating Entities
@@ -126,19 +126,19 @@ The engine recognizes these standard keys. Use them to integrate with the physic
| ~#:anim-tick~ | integer | Tick counter for frame timing (0 to ~#:duration - 1~). Incremented by ~animate-entity~; resets when frame advances. |
| ~#:group-id~ | symbol | Shared id for one rigid assembly (from ~instantiate-group-prefab~). All parts and the origin share the same symbol. |
| ~#:group-origin?~ | boolean | When ~#t~, this entity is the assembly’s pose origin; world ~#:x~ / ~#:y~ drive the group. Members should not set this. |
-| ~#:group-local-x~, ~#:group-local-y~ | number | Offset from the origin’s top-left corner; members’ world position is origin + local (updated by ~scene-sync-groups~). |
+| ~#:group-local-x~, ~#:group-local-y~ | number | Offset from the origin’s top-left corner; members’ world position is origin + local (updated by ~sync-groups~ on the entity list, e.g. ~(scene-transform-entities scene sync-groups)~). |
| ~#:skip-render~ | boolean | When ~#t~, ~render-scene!~ skips drawing this entity (used for invisible origins). |
* Entity groups (prefab assemblies)
A **group prefab** describes one *origin* entity plus several *parts* with local offsets. Data lives in the optional ~group-prefabs~ section of the prefab file (alongside ~mixins~ and ~prefabs~). Each group entry has the shape ~(name #:type-members SYMBOL #:parts (part ...) ...)~ with two optional flags:
-- ~#:pose-only-origin?~ — when ~#t~ (typical for tweened platforms), the origin is invisible, does not run physics pipelines, and is driven by tweens or scripts. When ~#f~ (default), the origin uses a small *physics-driving* profile (~#:gravity? #t~, no ~#:skip-pipelines~): integrate the origin like a mover, then call ~scene-sync-groups~ so parts stay glued as a rigid body. For that case, set ~#:origin-width~ and ~#:origin-height~ to the full assembly size (same box as the combined parts); otherwise the origin stays 0×0 and tile collision only sees a point at the reference corner, which can leave the raft overlapping solid floor tiles.
+- ~#:pose-only-origin?~ — when ~#t~ (typical for tweened platforms), the origin is invisible, does not run physics pipelines, and is driven by tweens or scripts. When ~#f~ (default), the origin uses a small *physics-driving* profile (~#:gravity? #t~, no ~#:skip-pipelines~): integrate the origin like a mover, then ~(scene-transform-entities scene sync-groups)~ so parts stay glued as a rigid body. For that case, set ~#:origin-width~ and ~#:origin-height~ to the full assembly size (same box as the combined parts); otherwise the origin stays 0×0 and tile collision only sees a point at the reference corner, which can leave the raft overlapping solid floor tiles.
- ~#:static-parts?~ — when ~#t~, each part gets static rigid-body defaults (no gravity on parts; pose comes from the origin). When ~#f~ (default), parts only have what you put in each part plist.
Each ~part~ is a plist using ~#:local-x~ / ~#:local-y~ (or ~#:group-local-x~ / ~#:group-local-y~) and the usual ~#:width~, ~#:height~, ~#:tile-id~, physics keys, etc.
-Use ~(instantiate-group-prefab registry 'name origin-x origin-y)~ from ~downstroke-prefabs~ to obtain ~(origin member ...)~. Append all of them to the scene. After moving origins (tweens and/or physics), ensure updated origins are in ~scene-entities~, then call ~(scene-sync-groups scene)~ so every part’s ~#:x~ / ~#:y~ matches the origin plus local offsets (see ~docs/api.org~ for ordering).
+Use ~(instantiate-group-prefab registry 'name origin-x origin-y)~ from ~downstroke-prefabs~ to obtain ~(origin member ...)~. Append all of them to the scene. After moving origins (tweens and/or physics), ensure updated origins are in ~scene-entities~, then ~(scene-transform-entities scene sync-groups)~ so every part’s ~#:x~ / ~#:y~ matches the origin plus local offsets (see ~docs/api.org~ for ordering).
* Entities in Scenes
@@ -168,13 +168,13 @@ Returns a new scene with the entity appended to the entity list.
(scene-add-entity scene new-enemy)
#+end_src
-** ~scene-update-entities scene proc1 proc2 ...~
+** ~scene-map-entities scene proc1 proc2 ...~
Maps each procedure over the scene's entities, applying them in sequence. Each proc must be a function of one entity, returning a new entity.
#+begin_src scheme
;; Apply physics pipeline to all entities:
-(scene-update-entities scene
+(scene-map-entities scene
apply-gravity
apply-velocity-x
apply-velocity-y)
@@ -184,9 +184,9 @@ The result is equivalent to:
#+begin_src scheme
(chain scene
- (scene-update-entities _ apply-gravity)
- (scene-update-entities _ apply-velocity-x)
- (scene-update-entities _ apply-velocity-y))
+ (scene-map-entities _ apply-gravity)
+ (scene-map-entities _ apply-velocity-x)
+ (scene-map-entities _ apply-velocity-y))
#+end_src
** ~scene-filter-entities scene pred~