summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Thompson <dthompson2@worcester.edu>2023-10-28 17:30:12 -0400
committerDavid Thompson <dthompson2@worcester.edu>2023-10-28 21:47:35 -0400
commit6c834216023a60ee94f0bf475df84d041c4443cd (patch)
tree84d29cbab2a46d1fff3dab20a4a5a387980bc6b5
parent9ba900dbf6497643d3ae1ec2dc6908694527173f (diff)
Animations!
-rw-r--r--game.scm31
-rw-r--r--images/player.asebin658 -> 1773 bytes
-rw-r--r--images/player.pngbin605 -> 1265 bytes
-rw-r--r--images/turret.asebin470 -> 993 bytes
-rw-r--r--images/turret.pngbin250 -> 490 bytes
5 files changed, 20 insertions, 11 deletions
diff --git a/game.scm b/game.scm
index 441298c..b0daad0 100644
--- a/game.scm
+++ b/game.scm
@@ -931,7 +931,7 @@
(spawn-enemy
(make-enemy 'turret 10 (vec2 x y) (vec2 12.0 12.0)
(vec2 0.0 0.0) script 100
- #(0.0 0.0 0.0 0.0) image:turret (vec2 32.0 32.0))))
+ #(0.0 16.0 32.0 48.0) image:turret (vec2 16.0 16.0))))
(define (spawn-popcorn* x y script)
(spawn-enemy
@@ -1011,6 +1011,7 @@
;; Player state:
(define player-position (vec2 (/ game-width 2.0) (- game-height 12.0)))
(define player-velocity (vec2 0.0 0.0))
+ (define *player-tile-x* 0.0)
(define player-speed 2.9)
(define player-focus-speed 1.5)
(define player-bullet-speed 12.3)
@@ -1042,7 +1043,13 @@
(vec2-mul-scalar! player-velocity
(if (focusing?)
player-focus-speed
- player-speed)))))
+ player-speed))
+ (set! *player-tile-x*
+ (* (cond
+ ((and left? (not right?)) 1.0)
+ ((and right? (not left?)) 3.0)
+ (else 0.0))
+ player-width)))))
(define (set-left! pressed?)
(vector-set! key-state 0 pressed?)
(update-player-velocity!))
@@ -1154,14 +1161,15 @@
0.0 (- player-bullet-speed)))))
(set! *player-fire-counter* 0))))
(define (draw-player)
- (draw-image context image:player
- (if *player-visible?* 0.0 player-width) 0.0
- player-width player-height
- (- (vec2-x player-position)
- (/ player-width 2.0))
- (- (vec2-y player-position)
- (/ player-height 2.0))
- player-width player-height)
+ (when *player-visible?*
+ (draw-image context image:player
+ *player-tile-x* 0.0
+ player-width player-height
+ (- (vec2-x player-position)
+ (/ player-width 2.0))
+ (- (vec2-y player-position)
+ (/ player-height 2.0))
+ player-width player-height))
(when *debug?*
(set-fill-color! context "#ff00ff80")
(fill-rect context
@@ -1233,7 +1241,7 @@
(set-scale! context *canvas-scale* *canvas-scale*)
(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-bg 0.3)
(draw-background image:starfield-fg 0.5)
(draw-level-foreground level)
(draw-particles particles)
@@ -1275,6 +1283,7 @@
(enemy-pool-reset! enemies)
(particle-pool-reset! particles)
(player-position-reset!)
+ (set! *player-tile-x* 0.0)
(set! *player-lives* %default-lives)
(set! *player-invincible?* #f)
(set! *player-visible?* #t)
diff --git a/images/player.ase b/images/player.ase
index 0a688d7..198b214 100644
--- a/images/player.ase
+++ b/images/player.ase
Binary files differ
diff --git a/images/player.png b/images/player.png
index 03f2251..5ffb92a 100644
--- a/images/player.png
+++ b/images/player.png
Binary files differ
diff --git a/images/turret.ase b/images/turret.ase
index 80601de..dd1fe3d 100644
--- a/images/turret.ase
+++ b/images/turret.ase
Binary files differ
diff --git a/images/turret.png b/images/turret.png
index 8da1a03..d20852f 100644
--- a/images/turret.png
+++ b/images/turret.png
Binary files differ