From 3c38445f3c04b43641347a609e1eb6b1dc2396cb Mon Sep 17 00:00:00 2001 From: David Thompson Date: Wed, 25 Oct 2023 08:44:24 -0400 Subject: Fix stationary enemy movement. --- game.scm | 5 ++++- level.tmx | 3 ++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/game.scm b/game.scm index 23618c2..f3cafdd 100644 --- a/game.scm +++ b/game.scm @@ -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) diff --git a/level.tmx b/level.tmx index 2191ef4..c16eb72 100644 --- a/level.tmx +++ b/level.tmx @@ -1,5 +1,5 @@ - + @@ -137,5 +137,6 @@ + -- cgit v1.2.3