summaryrefslogtreecommitdiff
path: root/game.scm
diff options
context:
space:
mode:
authorDavid Thompson <dthompson2@worcester.edu>2023-10-28 15:38:42 -0400
committerDavid Thompson <dthompson2@worcester.edu>2023-10-28 15:38:42 -0400
commit6128c495562f0aa9aa805b38bb5e153c1a175212 (patch)
tree65fdafabcb71e1ec530377240e9e54270fe88a0f /game.scm
parente48620fc1b5a8ba4d8a3b58963750a3af85f1242 (diff)
Use starfield background.
Diffstat (limited to 'game.scm')
-rw-r--r--game.scm28
1 files changed, 17 insertions, 11 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)