summaryrefslogtreecommitdiff
path: root/lisparuga/enemy.scm
diff options
context:
space:
mode:
Diffstat (limited to 'lisparuga/enemy.scm')
-rw-r--r--lisparuga/enemy.scm10
1 files changed, 9 insertions, 1 deletions
diff --git a/lisparuga/enemy.scm b/lisparuga/enemy.scm
index 0589d16..aa5335e 100644
--- a/lisparuga/enemy.scm
+++ b/lisparuga/enemy.scm
@@ -21,6 +21,7 @@
;;; Code:
(define-module (lisparuga enemy)
+ #:use-module (chickadee audio)
#:use-module (chickadee math)
#:use-module (chickadee math rect)
#:use-module (chickadee math vector)
@@ -46,6 +47,9 @@
;;;
;;; Base Enemy
;;;
+
+(define-asset explosion-sound (load-audio (scope-asset "sounds/explosion.wav")))
+
(define-class <enemy> (<actor>)
(health #:accessor health #:init-keyword #:health)
(points #:getter points #:init-keyword #:points)
@@ -56,7 +60,11 @@
#t)
(define-method (damage (enemy <enemy>) x)
- (set! (health enemy) (max (- (health enemy) x) 0)))
+ (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))))
(define-method (dead? (enemy <enemy>))
(zero? (health enemy)))