diff options
author | David Thompson <dthompson2@worcester.edu> | 2023-10-25 08:44:24 -0400 |
---|---|---|
committer | David Thompson <dthompson2@worcester.edu> | 2023-10-25 08:44:24 -0400 |
commit | 3c38445f3c04b43641347a609e1eb6b1dc2396cb (patch) | |
tree | 22b372a2cf7c5e5de4ddc89b85205b5c4b49817a | |
parent | 3a1afc62724f1631f23b5aa044856f7d09db14eb (diff) |
Fix stationary enemy movement.
-rw-r--r-- | game.scm | 5 | ||||
-rw-r--r-- | level.tmx | 3 |
2 files changed, 6 insertions, 2 deletions
@@ -462,6 +462,7 @@ ;; Scrolling level: (define *scroll* 0.0) + (define *last-scroll* 0.0) (define *scroll-speed* 0.5) (define *last-row-scanned* 0) ;; action id, sprite sheet offset, x, y @@ -545,6 +546,7 @@ (match level (#('level height foreground background collision objects) (let ((scroll (min (+ *scroll* *scroll-speed*) max-scroll))) + (set! *last-scroll* *scroll*) (set! *scroll* scroll) (let ((row (max (- (trunc (/ (- (* height tile-height) @@ -620,7 +622,7 @@ (match enemy (#('enemy _ _ position size stationary? velocity _) (if stationary? - (set-vec2-y! position (+ (vec2-y position) *scroll-speed*)) + (set-vec2-y! position (+ (vec2-y position) (- *scroll* *last-scroll*))) (begin (set-vec2-x! position (+ (vec2-x position) (vec2-x velocity))) (set-vec2-y! position (+ (vec2-y position) (vec2-y velocity)))))))) @@ -925,6 +927,7 @@ (set! *game-state* 'play) (scheduler-reset! *scheduler*) (set! *scroll* 0.0) + (set! *last-scroll* 0.0) (set! *last-row-scanned* (level-height level)) (bullet-pool-reset! player-bullets) (bullet-pool-reset! enemy-bullets) @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8"?> -<map version="1.8" tiledversion="1.8.6" orientation="orthogonal" renderorder="right-down" width="15" height="40" tilewidth="16" tileheight="16" infinite="0" nextlayerid="6" nextobjectid="13"> +<map version="1.8" tiledversion="1.8.6" orientation="orthogonal" renderorder="right-down" width="15" height="40" tilewidth="16" tileheight="16" infinite="0" nextlayerid="6" nextobjectid="14"> <tileset firstgid="1" source="tiles.tsx"/> <layer id="2" name="background" width="15" height="40"> <data encoding="csv"> @@ -137,5 +137,6 @@ <object id="10" type="enemy-a" x="16" y="336" width="16" height="16"/> <object id="11" type="enemy-a" x="192" y="336" width="16" height="16"/> <object id="12" type="enemy-a" x="112" y="176" width="16" height="16"/> + <object id="13" type="enemy-a" x="112" y="0" width="16" height="16"/> </objectgroup> </map> |