Add particle effect when bomb explodes.

This commit is contained in:
David Thompson 2024-05-26 16:46:50 -04:00
parent 4feffecf8e
commit d725310239
3 changed files with 136 additions and 2 deletions

View file

@ -48,6 +48,7 @@
(game levels catboss-2)
(game levels catboss-3)
(game levels credits)
(game particles)
(game scripts)
(game tileset)
(game time)
@ -324,9 +325,22 @@
(('receive-electron x y)
(play-sound-effect audio:warp 0.25))
(('explosion x y)
;; TODO: Particles!
(play-sound-effect audio:explosion)
(show-effect! (make-screen-shake-effect 0.2)))
(show-effect! (make-screen-shake-effect 0.2))
(run-script
(lambda ()
(do ((i 0 (1+ i)))
((= i 16))
(do ((j 0 (1+ j)))
((= j 2))
(let ((angle (* (random) 2.0 pi))
(dx (- (* (random) tile-width 3.0) tile-width))
(dy (- (* (random) tile-height 3.0) tile-height)))
(particle-pool-add! particles 51 8
(+ (* x tile-width) dx)
(+ (* y tile-height) dy)
0.0 0.0)))
(wait 1)))))
(_ (values)))
(lp rest))))
(update-objects!)
@ -338,6 +352,7 @@
(define dt (/ 1000.0 60.0)) ; aim for updating at 60Hz
(define (update)
(scheduler-tick! (current-scheduler))
(particle-pool-update! particles)
(timeout update-callback dt))
(define update-callback (procedure->external update))
@ -405,6 +420,7 @@
(94 .4)
(114 .4))
(define particles (make-particle-pool 512 tileset))
(define number->string*
(let ((cache (make-eq-hashtable))) ; assuming fixnums only
@ -541,6 +557,7 @@
(define (draw-level)
(draw-background)
(for-each draw-object *objects*)
(draw-particles context particles)
(let ((alive? (with-goblins ($ (level-player *level*) 'alive?))))
(unless alive?
(set-global-alpha! context 0.7)