diff options
| author | Gene Pasquet <dev@etenil.net> | 2026-04-07 23:42:08 +0100 |
|---|---|---|
| committer | Gene Pasquet <dev@etenil.net> | 2026-04-07 23:42:08 +0100 |
| commit | cfddc2f180552afdb080968f847018c5a223b41a (patch) | |
| tree | 61f982e5ab20dc10c732c135d6e335531abface1 /demo | |
| parent | 19a5db8606a82830a5ccd0ed46d8e0cf3c95db0a (diff) | |
Use entities as platforms
Diffstat (limited to 'demo')
| -rw-r--r-- | demo/sandbox.scm | 42 |
1 files changed, 23 insertions, 19 deletions
diff --git a/demo/sandbox.scm b/demo/sandbox.scm index 2feb69e..ad2e056 100644 --- a/demo/sandbox.scm +++ b/demo/sandbox.scm @@ -15,30 +15,33 @@ (define *demo-t* 0.0) -;; Programmatic level: same geometry as the old static-tile floor + mid shelf, -;; but as a real tile layer so tile collisions and detect-on-solid work. +(define +static-skip+ + '(jump acceleration gravity velocity-x velocity-y + tile-collisions-x tile-collisions-y on-solid)) + +;; Mid-level shelf only: immovable solid AABBs (same layout as the old tilemap shelf). +(define (make-shelf-platform gw gh tw th) + (let* ((shelf-tile-id 20) + (shelf-c0 10) + (shelf-n 10) + (x0 (* shelf-c0 tw)) + (y (- gh (* 6 th)))) + (map (lambda (i) + (list #:type 'static-tile + #:x (+ x0 (* i tw)) #:y y #:width tw #:height th + #:tile-id shelf-tile-id #:solid? #t #:immovable? #t + #:gravity? #f #:vx 0 #:vy 0 #:on-ground? #f + #:skip-pipelines +static-skip+)) + (iota shelf-n)))) + +;; Floor only on the tilemap; shelf is entities (see make-shelf-platform). (define (make-sandbox-tilemap ts tw th gw gh) (let* ((ncols (inexact->exact (ceiling (/ gw tw)))) (nrows (inexact->exact (ceiling (/ gh th)))) (floor-tile 20) - (shelf-tile 20) (air (map (lambda (_) (map (lambda (_) 0) (iota ncols))) (iota nrows))) (floor-row (map (lambda (_) floor-tile) (iota ncols))) - (with-floor (append (take air (- nrows 1)) (list floor-row))) - ;; Shelf top at same Y as before: gh - 6*th pixels from top - (shelf-r (inexact->exact (floor (/ (- gh (* 6 th)) th)))) - (shelf-c0 10) - (shelf-n 10) - (row-before (list-ref with-floor shelf-r)) - (shelf-row - (map (lambda (c) - (if (and (>= c shelf-c0) (< c (+ shelf-c0 shelf-n))) - shelf-tile - (list-ref row-before c))) - (iota ncols))) - (map-data (append (take with-floor shelf-r) - (list shelf-row) - (drop with-floor (+ shelf-r 1)))) + (map-data (append (take air (- nrows 1)) (list floor-row))) (layer (make-layer name: "ground" width: ncols height: nrows map: map-data))) @@ -115,11 +118,12 @@ (gw (game-width game)) (gh (game-height game)) (tm (make-sandbox-tilemap ts tw th gw gh)) + (shelf (make-shelf-platform gw gh tw th)) (bots (list (make-demo-bot 80 80 tw th 0) (make-demo-bot 220 60 tw th 1) (make-demo-bot 380 100 tw th 2))) - (entities (append (spawn-boxes tw th) bots)) + (entities (append shelf (spawn-boxes tw th) bots)) (scene (make-scene entities: entities tilemap: tm |
