diff options
| author | Gene Pasquet <dev@etenil.net> | 2026-04-07 23:36:12 +0100 |
|---|---|---|
| committer | Gene Pasquet <dev@etenil.net> | 2026-04-07 23:36:12 +0100 |
| commit | 19a5db8606a82830a5ccd0ed46d8e0cf3c95db0a (patch) | |
| tree | 241e7376014068ab9fc7a1bc8fa7a29cc1b62490 /docs/guide.org | |
| parent | 618ed5fd6f5ae9c9f275c1e3cfb74762d7d51a01 (diff) | |
Work on demos
Diffstat (limited to 'docs/guide.org')
| -rw-r--r-- | docs/guide.org | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/docs/guide.org b/docs/guide.org index de07c82..380f04b 100644 --- a/docs/guide.org +++ b/docs/guide.org @@ -125,7 +125,7 @@ csc square.scm -o square Press arrow keys to move the yellow square around. Here are the key ideas: -- **Scenes**: =make-scene= creates a container for entities, tilemaps, and the camera. It holds the game state each frame. +- **Scenes**: =make-scene= creates a container for entities, tilemaps, and the camera. It holds the game state each frame. Optional =background:= ~(r g b)~ or ~(r g b a)~ sets the color used to clear the window each frame (default is black). - **Entities**: Entities are plists (property lists). They have no class; they're pure data. Access properties with =entity-ref=, and update with =entity-set= (which returns a *new* plist — always bind the result). - **Input**: =input-held?= returns =#t= if an action is currently pressed. Actions are symbols like ='left=, ='right=, ='up=, ='down= (from the default input config). - **Update & Render**: The =update:= hook runs first and updates entities. The =render:= hook runs after the default rendering pipeline and is used for custom drawing like this colored rectangle. @@ -193,7 +193,7 @@ For a real game, you probably want tilemaps, gravity, and collision detection. D (player (resolve-tile-collisions-x player tm)) (player (apply-velocity-y player)) (player (resolve-tile-collisions-y player tm)) - (player (detect-ground player tm))) + (player (detect-on-solid player tm))) ;; Update camera to follow player (let ((cam-x (max 0 (- (entity-ref player #:x 0) 300)))) (camera-x-set! (scene-camera scene) cam-x)) @@ -210,7 +210,7 @@ Key points: - **=play-sound=** plays a loaded sound effect. - **Physics pipeline**: Functions like =apply-gravity=, =apply-velocity-x=, =resolve-tile-collisions-x= form the physics pipeline. Apply them in order each frame to get correct platformer behavior. - **Tile collisions**: =resolve-tile-collisions-x= and =resolve-tile-collisions-y= snap entities to tile edges, preventing clipping. -- **Ground detection**: =detect-ground= sets the =#:on-ground?= flag so you know if a jump is valid. +- **On-solid check**: =detect-on-solid= sets the =#:on-ground?= flag from tiles below the feet and, if you pass other scene entities, from standing on solids (moving platforms, crates). Call it after collisions; use the flag next frame to gate jumps. (Despite the =?=-suffix, it returns an updated entity, not a boolean.) See =demo/platformer.scm= in the engine source for a complete working example. |
