summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--assets/images/explosion.pngbin0 -> 838 bytes
-rw-r--r--assets/images/explosion.xcfbin0 -> 2948 bytes
-rw-r--r--game.scm32
3 files changed, 27 insertions, 5 deletions
diff --git a/assets/images/explosion.png b/assets/images/explosion.png
new file mode 100644
index 0000000..44442b3
--- /dev/null
+++ b/assets/images/explosion.png
Binary files differ
diff --git a/assets/images/explosion.xcf b/assets/images/explosion.xcf
new file mode 100644
index 0000000..8652ec9
--- /dev/null
+++ b/assets/images/explosion.xcf
Binary files differ
diff --git a/game.scm b/game.scm
index a848392..7f6aecf 100644
--- a/game.scm
+++ b/game.scm
@@ -257,7 +257,7 @@
(add-enemy-bullets world bullets)))
(define (explosion-active? explosion current-time)
- (> (- current-time (explosion-time explosion)) 120))
+ (< (- current-time (explosion-time explosion)) 15))
;;;
@@ -670,6 +670,9 @@ each time KEY is pressed."
(define-signal enemy-tileset
(load-tileset/live "assets/images/enemies.png" 16 16))
+(define-signal explosion-tileset
+ (load-tileset/live "assets/images/explosion.png" 16 16))
+
(define-signal player-sprite
(signal-map-maybe (lambda (world tileset)
(make-sprite
@@ -717,6 +720,7 @@ each time KEY is pressed."
(define bullet-rect (make-rect -8 -8 16 16))
(define enemy-rect (make-rect -8 -8 16 16))
+(define explosion-rect (make-rect -8 -8 16 16))
(define (render-bullets bullets tileset batch)
(lambda (context)
@@ -771,6 +775,19 @@ each time KEY is pressed."
(move (player-position player)
(render-sprite sprite))))
+(define (render-explosions explosions tileset batch time)
+ (lambda (context)
+ (with-sprite-batch batch context
+ (for-each (lambda (explosion)
+ (let* ((start-time (explosion-time explosion))
+ (rect (rect-move explosion-rect
+ (explosion-position explosion)))
+ ;; 3 frames of animation.
+ (frame (min 2 (floor (/ (- time start-time) 5))))
+ (tex (tileset-ref tileset frame)))
+ (sprite-batch-add! batch context tex rect)))
+ explosions))))
+
(define-signal scene
(signal-let ((fps-text fps-text)
(score-text score-text)
@@ -783,28 +800,33 @@ each time KEY is pressed."
(player-sprite player-sprite)
(bullet-tileset bullet-tileset)
(enemy-tileset enemy-tileset)
+ (explosion-tileset explosion-tileset)
(batch batch)
(world world)
(time timer))
(if (and framebuffer framebuffer-sprite batch bullet-tileset
- enemy-tileset player-sprite)
+ enemy-tileset player-sprite explosion-tileset)
(let ((player (actor-ref (world-player world))))
(render-begin
(with-framebuffer framebuffer
(with-camera camera
(render-begin
background
+ (render-explosions (world-explosions world)
+ explosion-tileset
+ batch
+ time)
(render-bullets (world-player-bullets world)
bullet-tileset
batch)
(render-player player player-sprite time)
- (render-bullets (world-enemy-bullets world)
- bullet-tileset
- batch)
(render-enemies (world-enemies world)
enemy-tileset
batch
time)
+ (render-bullets (world-enemy-bullets world)
+ bullet-tileset
+ batch)
(with-color font-color
(render-begin
(if display-fps?