From 13aa8606a9c410e12efa8f6030e42b47f2367698 Mon Sep 17 00:00:00 2001 From: Juliana Sims Date: Thu, 23 May 2024 16:28:53 -0400 Subject: [PATCH] Implement interval logic for emitters --- game.scm | 2 +- modules/game/level.scm | 10 +++++++--- modules/game/levels/level-3.tmx | 23 ++++++++++++++++++---- modules/game/levels/level-4.tmx | 23 ++++++++++++++++++---- modules/game/levels/tiles.tsx | 2 -- scripts/compile-map.scm | 35 ++++++++++++++++++--------------- 6 files changed, 65 insertions(+), 30 deletions(-) diff --git a/game.scm b/game.scm index a59845d..b14e01f 100644 --- a/game.scm +++ b/game.scm @@ -379,7 +379,7 @@ (('exit pos) #t) ; drawn via background (('wall pos type) (draw-wall pos type)) (('block pos type) (draw-block pos type)) - (('clock-emitter pos) #t) ; drawn via background + (('clock-emitter pos) (draw-clock-emitter pos)) (('switched-emitter pos on?) (draw-switched-emitter pos on?)) (('floor-switch pos on?) (draw-floor-switch pos on?)) (('gem pos) (draw-gem pos)) diff --git a/modules/game/level.scm b/modules/game/level.scm index ffe34bd..52baed2 100644 --- a/modules/game/level.scm +++ b/modules/game/level.scm @@ -66,7 +66,8 @@ (4 (spawn ^exit x y)) (5 (spawn ^block x y 'copper)) (6 (spawn ^block x y 'crate)) - (7 (spawn ^clock-emitter x y 4)) + (7 (spawn ^clock-emitter x y + (bytevector-u8-ref objects (+ i 3)))) (8 (let ((target-x (bytevector-u8-ref objects (+ i 3))) (target-y (bytevector-u8-ref objects (+ i 4)))) (spawn ^floor-switch x y target-x target-y))) @@ -86,15 +87,18 @@ (spawn ^electron-warp x y target-x target-y))) (15 (spawn ^or-gate x y (bytevector-u8-ref objects (+ i 3)))) - (16 (spawn ^switched-emitter x y 4)) + (16 (spawn ^switched-emitter x y + (bytevector-u8-ref objects (+ i 3)))) (id (error "invalid level object" id)))) (i* (+ i (match id ;; floor-switch ;; electric-switch ;; electron-warp ((or 8 12 14) 5) + ;; clock-emitter ;; logic gates - ((or 11 13 15) 4) + ;; switched-emitter + ((or 7 11 13 15 16) 4) (_ 3))))) (when obj ($ level* 'add-object obj)) diff --git a/modules/game/levels/level-3.tmx b/modules/game/levels/level-3.tmx index cc1d396..fe492a7 100644 --- a/modules/game/levels/level-3.tmx +++ b/modules/game/levels/level-3.tmx @@ -1,5 +1,5 @@ - + @@ -7,13 +7,13 @@ 81,83,83,82,83,83,83,82,83,83,83,83,82,83,83,84,23,23,23,23, 85,24,24,24,24,24,24,24,24,24,24,24,24,24,24,106,81,82,82,84, 105,24,24,24,24,24,24,24,24,24,24,24,24,24,24,106,105,24,24,86, -105,24,49,3,3,24,3,3,3,3,3,3,24,24,24,106,105,24,24,106, +105,24,24,3,3,24,3,3,3,3,3,3,24,24,24,106,105,24,24,106, 85,24,24,24,24,24,24,24,24,24,24,24,24,3,24,106,105,24,24,106, -85,24,24,24,24,24,49,3,3,3,3,3,24,24,24,24,24,24,24,106, +85,24,24,24,24,24,24,3,3,3,3,3,24,24,24,24,24,24,24,106, 85,24,24,24,24,24,24,24,24,24,24,24,24,24,24,106,105,24,24,106, 85,24,24,24,24,24,24,24,24,24,24,24,24,24,24,106,105,28,24,86, 105,24,24,24,24,24,24,24,24,24,24,24,24,24,81,104,105,24,24,86, -105,49,3,3,24,61,61,66,24,24,24,24,24,24,106,23,105,24,24,86, +105,24,3,3,24,61,61,66,24,24,24,24,24,24,106,23,105,24,24,86, 85,24,24,24,24,24,24,64,61,61,24,3,3,24,86,23,101,102,102,104, 101,103,103,102,102,102,103,102,103,103,102,102,102,102,104,23,23,23,23,23, 23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23, @@ -57,5 +57,20 @@ + + + + + + + + + + + + + + + diff --git a/modules/game/levels/level-4.tmx b/modules/game/levels/level-4.tmx index c27cef9..ad734e4 100644 --- a/modules/game/levels/level-4.tmx +++ b/modules/game/levels/level-4.tmx @@ -1,5 +1,5 @@ - + @@ -8,11 +8,11 @@ 23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23, 23,23,24,24,24,24,24,24,24,24,24,24,24,24,23,23,23,23,23,23, 23,24,24,24,24,24,24,24,24,24,24,24,24,24,24,23,24,24,24,23, -23,24,24,24,24,49,3,24,3,24,24,24,24,24,24,23,24,28,24,23, +23,24,24,24,24,24,3,24,3,24,24,24,24,24,24,23,24,28,24,23, 23,24,24,24,24,24,24,24,24,24,3,24,24,24,24,23,24,24,24,23, -23,24,24,24,24,48,3,3,3,24,24,24,3,24,24,24,24,24,24,23, +23,24,24,24,24,24,3,3,3,24,24,24,3,24,24,24,24,24,24,23, 23,24,24,24,24,24,24,24,24,24,3,24,24,24,24,23,24,24,24,23, -23,24,49,3,3,24,3,3,3,24,24,24,24,24,24,23,24,24,24,23, +23,24,24,3,3,24,3,3,3,24,24,24,24,24,24,23,24,24,24,23, 23,24,24,24,24,24,24,24,24,24,24,24,24,24,24,23,24,24,24,23, 23,23,24,24,24,24,24,24,24,24,24,24,24,24,23,23,23,23,23,23, 23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23, @@ -55,5 +55,20 @@ + + + + + + + + + + + + + + + diff --git a/modules/game/levels/tiles.tsx b/modules/game/levels/tiles.tsx index 31efecd..b8335e5 100644 --- a/modules/game/levels/tiles.tsx +++ b/modules/game/levels/tiles.tsx @@ -12,8 +12,6 @@ - - diff --git a/scripts/compile-map.scm b/scripts/compile-map.scm index cb93e62..5cd754c 100644 --- a/scripts/compile-map.scm +++ b/scripts/compile-map.scm @@ -575,22 +575,21 @@ the default ORIENTATION value of 'orthogonal' is supported." (layer (tile-map-layer-ref tile-map layer-name))) (append-map (lambda (y) (concatenate - (filter-map (lambda (x) - (match (tile-layer-ref layer x y) - (#f #f) - ((= map-tile-ref tile) - (match (tile-type tile) - (#f #f) - ("wall" - (match (assq-ref (tile-properties tile) 'kind) - ("brick" (list x y obj:wall:brick)) - ("copper" (list x y obj:wall:copper)) - (kind (error "unsupported wall kind" kind)))) - ("exit" (list x y obj:exit)) - ("clock-emitter" (list x y obj:clock-emitter)) - ("switched-emitter" (list x y obj:switched-emitter)) - (type (error "unsupported background object" type)))))) - (iota (tile-layer-width layer))))) + (filter-map + (lambda (x) + (match (tile-layer-ref layer x y) + (#f #f) + ((= map-tile-ref tile) + (match (tile-type tile) + (#f #f) + ("wall" + (match (assq-ref (tile-properties tile) 'kind) + ("brick" (list x y obj:wall:brick)) + ("copper" (list x y obj:wall:copper)) + (kind (error "unsupported wall kind" kind)))) + ("exit" (list x y obj:exit)) + (type (error "unsupported background object" type)))))) + (iota (tile-layer-width layer))))) (iota (tile-layer-height layer))))) (define (compile-object-layer tile-map layer-name) @@ -621,6 +620,10 @@ the default ORIENTATION value of 'orthogonal' is supported." (assq-ref properties 'target-y))) ('gem (list x y obj:gem)) ('gate (list x y obj:gate)) + ('clock-emitter (list x y obj:clock-emitter + (assq-ref properties 'interval))) + ('switched-emitter (list x y obj:switched-emitter + (assq-ref properties 'interval))) ('and-gate (list x y obj:and-gate (parse-direction (assq-ref properties 'direction))))