From 6128c495562f0aa9aa805b38bb5e153c1a175212 Mon Sep 17 00:00:00 2001 From: David Thompson Date: Sat, 28 Oct 2023 15:38:42 -0400 Subject: Use starfield background. --- game.scm | 28 +++++---- images/starfield-bg.png | Bin 519 -> 758 bytes level.tmx | 151 ++++++++++++++++++++++++++++++------------------ 3 files changed, 113 insertions(+), 66 deletions(-) diff --git a/game.scm b/game.scm index 296dc3a..66b79bf 100644 --- a/game.scm +++ b/game.scm @@ -320,7 +320,8 @@ ;; Elements (define canvas (get-element-by-id "canvas")) (define context (get-context canvas "2d")) - (define image:background (load-image "images/background.png")) + (define image:starfield-bg (load-image "images/starfield-bg.png")) + (define image:starfield-fg (load-image "images/starfield-fg.png")) (define image:player (load-image "images/player.png")) (define image:player-bullets (load-image "images/player-bullets.png")) (define image:enemy-bullets (load-image "images/enemy-bullets.png")) @@ -735,10 +736,10 @@ (let ((scroll (min (+ *scroll* *scroll-speed*) max-scroll))) (set! *last-scroll* *scroll*) (set! *scroll* scroll) - (let ((row (max (- (truncate - (/ (- (* height tile-height) - game-height scroll) - tile-height)) 2) + (let ((row (max (truncate + (/ (- (* height tile-height) + game-height scroll) + tile-height)) 0))) (do ((y row (+ y 1))) ((= y *last-row-scanned*)) @@ -747,7 +748,7 @@ (#('level-object x type properties) (let ((x* (+ (* x tile-width) (/ tile-width 2.0))) - (y* (+ (* (- y row 3) tile-height) + (y* (+ (* (- y row 1) tile-height) (/ tile-height 2.0)))) (do-level-action type x* y* properties))))) (vector-ref objects y))) @@ -1129,7 +1130,7 @@ (let ((y-off 6.0)) (muzzle-flash px (- py y-off)) (bullet-pool-add! player-bullets 1 - px py + (- px 1.0) py 6.0 6.0 0.0 (- player-bullet-speed))) (let ((hbw 3.0) @@ -1226,7 +1227,10 @@ (clear-screen) (set-transform! context 1.0 0.0 0.0 1.0 0.0 0.0) (set-scale! context *canvas-scale* *canvas-scale*) - (draw-background image:background 0.75) + (set-fill-color! context "#140c1c") + (fill-rect context 0.0 0.0 game-width game-height) + (draw-background image:starfield-bg 0.2) + (draw-background image:starfield-fg 0.5) (draw-level-foreground level) (draw-particles particles) (draw-player-bullets) @@ -1256,10 +1260,12 @@ (define (reset!) (set! *game-state* 'play) (scheduler-reset! *scheduler*) - (set! *scroll* 0.0) - ;; (set! *scroll* (* 250.0 tile-height)) + ;; (set! *scroll* 0.0) + (set! *scroll* (* 250.0 tile-height)) (set! *last-scroll* 0.0) - (set! *last-row-scanned* (level-height level)) + ;; (set! *last-row-scanned* (level-height level)) + (set! *last-row-scanned* (- (level-height level) + 250)) (bullet-pool-reset! player-bullets) (bullet-pool-reset! enemy-bullets) (enemy-pool-reset! enemies) diff --git a/images/starfield-bg.png b/images/starfield-bg.png index 943d767..1115ef9 100644 Binary files a/images/starfield-bg.png and b/images/starfield-bg.png differ diff --git a/level.tmx b/level.tmx index 4b0ab00..68a4798 100644 --- a/level.tmx +++ b/level.tmx @@ -1,5 +1,5 @@ - + @@ -130,33 +130,33 @@ 1,1,1,1,1,1,0,0,0,0,0,0,0,0,1, 1,1,1,1,1,1,0,0,0,0,0,0,0,0,1, 1,1,1,1,1,1,0,0,0,0,0,0,0,0,1, -1,1,1,1,1,1,0,0,0,0,1,1,1,1,1, -1,1,1,1,1,1,0,0,0,0,1,1,1,1,1, -1,1,1,1,1,1,0,0,0,0,1,1,1,1,1, -1,1,1,1,1,1,0,0,0,0,1,1,1,1,1, -1,1,1,1,1,1,0,0,0,0,1,1,1,1,1, -1,0,0,0,0,0,0,0,0,0,1,1,1,1,1, -1,0,0,0,0,0,0,0,0,0,1,1,1,1,1, -1,0,0,0,0,0,0,0,0,0,1,1,1,1,1, -1,0,0,0,0,0,0,0,0,0,1,1,1,1,1, -1,0,0,0,0,1,1,1,1,1,1,1,1,1,1, -1,0,0,0,0,1,1,1,1,1,1,1,1,1,1, -1,0,0,0,0,1,1,1,1,1,1,1,1,1,1, -1,0,0,0,0,1,1,1,1,1,1,1,1,1,1, -1,0,0,0,0,1,1,1,1,1,1,1,1,1,1,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