summaryrefslogtreecommitdiff
path: root/bonnie-bee/moth.scm
diff options
context:
space:
mode:
authorDavid Thompson <dthompson@vistahigherlearning.com>2021-10-21 19:33:42 -0400
committerDavid Thompson <dthompson@vistahigherlearning.com>2021-10-21 19:33:42 -0400
commit10b02b1fb15b76c8037760f2a3e8dc3601759f28 (patch)
tree130d2531d8abf7d4b63873ed938959b57e354fd8 /bonnie-bee/moth.scm
parentac7bd2ccf3111575a549366e66bbf19b75785cf8 (diff)
Add roughly finished level.
Diffstat (limited to 'bonnie-bee/moth.scm')
-rw-r--r--bonnie-bee/moth.scm42
1 files changed, 42 insertions, 0 deletions
diff --git a/bonnie-bee/moth.scm b/bonnie-bee/moth.scm
new file mode 100644
index 0000000..8f4ed5f
--- /dev/null
+++ b/bonnie-bee/moth.scm
@@ -0,0 +1,42 @@
+(define-module (bonnie-bee moth)
+ #:use-module (bonnie-bee actor)
+ #:use-module (bonnie-bee assets)
+ #:use-module (bonnie-bee bullet)
+ #:use-module (chickadee audio)
+ #:use-module (chickadee graphics particles)
+ #:use-module (chickadee math)
+ #:use-module (chickadee math rect)
+ #:use-module (chickadee math vector)
+ #:use-module (chickadee scripting)
+ #:use-module (chickadee utils)
+ #:use-module (oop goops)
+ #:use-module (starling asset)
+ #:use-module (starling node)
+ #:use-module (starling node-2d)
+ #:export (<moth>))
+
+(define-class <moth> (<damageable> <actor>))
+
+(define-method (on-boot (moth <moth>))
+ (attach-to moth
+ (make <sprite>
+ #:texture moth-image
+ #:origin (vec2 32.0 32.0))))
+
+(define-method (on-collide (moth <moth>) (bullet <bullet>))
+ (cond
+ ((player-primary-bullet? bullet)
+ (damage moth 1)
+ (kill-bullet bullet)
+ #t)
+ ((player-bomb-bullet? bullet)
+ (damage moth 10)
+ (kill-bullet bullet))
+ (else #f)))
+
+(define-method (on-death (moth <moth>))
+ (audio-play (asset-ref explosion-sound))
+ (let ((p (position moth)))
+ (add-particle-emitter (particles (particles (parent moth)))
+ (make-particle-emitter (make-rect (vec2-x p) (vec2-y p) 1.0 1.0)
+ 4 3))))