diff options
author | David Thompson <dthompson@vistahigherlearning.com> | 2020-04-14 17:02:17 -0400 |
---|---|---|
committer | David Thompson <dthompson@vistahigherlearning.com> | 2020-04-14 17:02:17 -0400 |
commit | f08e14fd51e2b1f5920ac6816774c5e72cbee5c0 (patch) | |
tree | 3ed2df4b9c78ca2872b8af2aa91ed3dbff004351 /lisparuga/enemy.scm | |
parent | 2bdb665cffff93721bbd38b3809a7c420dff2f1c (diff) |
Day 4 progress.
Diffstat (limited to 'lisparuga/enemy.scm')
-rw-r--r-- | lisparuga/enemy.scm | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/lisparuga/enemy.scm b/lisparuga/enemy.scm index aa5335e..06533ea 100644 --- a/lisparuga/enemy.scm +++ b/lisparuga/enemy.scm @@ -49,6 +49,7 @@ ;;; (define-asset explosion-sound (load-audio (scope-asset "sounds/explosion.wav"))) +(define-asset hit-sound (load-audio (scope-asset "sounds/hit.wav"))) (define-class <enemy> (<actor>) (health #:accessor health #:init-keyword #:health) @@ -56,15 +57,14 @@ (parting-shots #:getter parting-shots #:init-keyword #:parting-shots) (fire-parting-shots? #:accessor fire-parting-shots? #:init-form #f)) -(define-method (on-kill (enemy <enemy>)) - #t) - (define-method (damage (enemy <enemy>) x) (let ((new-health (max (- (health enemy) x) 0))) (set! (health enemy) new-health) - (when (zero? new-health) - (audio-play (asset-ref explosion-sound) - #:volume 0.5)))) + (if (zero? new-health) + (audio-play (asset-ref explosion-sound) + #:volume 0.5) + (audio-play (asset-ref hit-sound) + #:volume 0.5)))) (define-method (dead? (enemy <enemy>)) (zero? (health enemy))) |