diff options
author | David Thompson <dthompson2@worcester.edu> | 2023-10-28 15:38:42 -0400 |
---|---|---|
committer | David Thompson <dthompson2@worcester.edu> | 2023-10-28 15:38:42 -0400 |
commit | 6128c495562f0aa9aa805b38bb5e153c1a175212 (patch) | |
tree | 65fdafabcb71e1ec530377240e9e54270fe88a0f | |
parent | e48620fc1b5a8ba4d8a3b58963750a3af85f1242 (diff) |
Use starfield background.
-rw-r--r-- | game.scm | 28 | ||||
-rw-r--r-- | images/starfield-bg.png | bin | 519 -> 758 bytes | |||
-rw-r--r-- | level.tmx | 151 |
3 files changed, 113 insertions, 66 deletions
@@ -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 Binary files differindex 943d767..1115ef9 100644 --- a/images/starfield-bg.png +++ b/images/starfield-bg.png @@ -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="500" tilewidth="16" tileheight="16" infinite="0" nextlayerid="8" nextobjectid="170"> +<map version="1.8" tiledversion="1.8.6" orientation="orthogonal" renderorder="right-down" width="15" height="500" tilewidth="16" tileheight="16" infinite="0" nextlayerid="8" nextobjectid="256"> <tileset firstgid="1" source="tiles.tsx"/> <tileset firstgid="7" source="background.tsx"/> <objectgroup id="7" name="background" visible="0" parallaxy="0.75"> @@ -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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,6, +6,6,0,0,0,6,6,6,6,6,6,6,6,6,6, +6,6,0,0,0,6,6,6,6,6,6,6,6,6,6, +6,6,0,0,0,6,6,6,6,6,6,6,6,6,6, +6,6,0,0,0,6,6,6,6,6,6,6,6,6,6, +6,6,0,0,0,6,6,6,6,6,6,6,6,6,6, +6,6,0,0,0,6,6,6,6,6,6,6,6,6,6, +6,6,0,0,0,6,6,6,6,6,6,6,6,6,6, +6,6,0,0,0,6,6,6,6,6,6,6,6,6,6, +6,6,0,0,0,6,6,6,6,6,6,6,6,6,6, +6,6,0,0,0,6,6,6,6,6,6,6,6,6,6, +6,6,0,0,0,6,6,6,6,6,6,6,6,6,6, 6,0,0,0,0,0,0,0,0,0,0,0,0,0,6, 6,0,0,0,0,0,0,0,0,0,0,0,0,0,6, 6,0,0,0,0,0,0,0,0,0,0,0,0,0,6, @@ -1185,5 +1185,46 @@ <property name="speed" type="float" value="2"/> </properties> </object> + <object id="177" type="popcorn" x="112" y="1984" width="16" height="16"/> + <object id="179" type="popcorn" x="112" y="1952" width="16" height="16"/> + <object id="181" type="popcorn" x="112" y="1920" width="16" height="16"/> + <object id="185" type="popcorn" x="192" y="1872" width="16" height="16"/> + <object id="186" type="popcorn" x="192" y="1840" width="16" height="16"/> + <object id="187" type="popcorn" x="192" y="1808" width="16" height="16"/> + <object id="188" type="popcorn" x="192" y="1776" width="16" height="16"/> + <object id="189" type="popcorn" x="192" y="1744" width="16" height="16"/> + <object id="190" type="popcorn" x="144" y="1648" width="16" height="16"/> + <object id="191" type="popcorn" x="144" y="1616" width="16" height="16"/> + <object id="192" type="popcorn" x="144" y="1584" width="16" height="16"/> + <object id="193" type="popcorn" x="144" y="1552" width="16" height="16"/> + <object id="194" type="popcorn" x="80" y="1472" width="16" height="16"/> + <object id="196" type="popcorn" x="80" y="1440" width="16" height="16"/> + <object id="197" type="popcorn" x="80" y="1408" width="16" height="16"/> + <object id="198" type="popcorn" x="160" y="1360" width="16" height="16"/> + <object id="199" type="popcorn" x="160" y="1328" width="16" height="16"/> + <object id="200" type="popcorn" x="160" y="1296" width="16" height="16"/> + <object id="201" type="popcorn" x="160" y="1264" width="16" height="16"/> + <object id="202" type="popcorn" x="160" y="1232" width="16" height="16"/> + <object id="203" type="popcorn" x="160" y="1200" width="16" height="16"/> + <object id="204" type="popcorn" x="160" y="1168" width="16" height="16"/> + <object id="205" type="popcorn" x="160" y="1136" width="16" height="16"/> + <object id="206" type="popcorn" x="160" y="1104" width="16" height="16"/> + <object id="207" type="turret" x="48" y="496" width="16" height="16"/> + <object id="208" type="turret" x="144" y="496" width="16" height="16"/> + <object id="209" type="turret" x="16" y="656" width="16" height="16"/> + <object id="210" type="turret" x="80" y="656" width="16" height="16"/> + <object id="211" type="turret" x="144" y="656" width="16" height="16"/> + <object id="212" type="turret" x="208" y="656" width="16" height="16"/> + <object id="213" type="popcorn" x="192" y="1712" width="16" height="16"/> + <object id="217" type="popcorn" x="48" y="2352" width="16" height="16"/> + <object id="218" type="popcorn" x="48" y="2320" width="16" height="16"/> + <object id="219" type="popcorn" x="48" y="2288" width="16" height="16"/> + <object id="220" type="popcorn" x="48" y="2256" width="16" height="16"/> + <object id="221" type="popcorn" x="48" y="2224" width="16" height="16"/> + <object id="222" type="popcorn" x="48" y="2192" width="16" height="16"/> + <object id="223" type="popcorn" x="48" y="2096" width="16" height="16"/> + <object id="224" type="popcorn" x="48" y="2128" width="16" height="16"/> + <object id="225" type="popcorn" x="48" y="2160" width="16" height="16"/> + <object id="226" type="popcorn" x="48" y="2064" width="16" height="16"/> </objectgroup> </map> |