From f08e14fd51e2b1f5920ac6816774c5e72cbee5c0 Mon Sep 17 00:00:00 2001 From: David Thompson Date: Tue, 14 Apr 2020 17:02:17 -0400 Subject: Day 4 progress. --- lisparuga/enemy.scm | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'lisparuga/enemy.scm') 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 () (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 )) - #t) - (define-method (damage (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 )) (zero? (health enemy))) -- cgit v1.2.3