summaryrefslogtreecommitdiff
path: root/bonnie-bee/flower.scm
diff options
context:
space:
mode:
authorDavid Thompson <dthompson@vistahigherlearning.com>2021-10-16 16:22:08 -0400
committerDavid Thompson <dthompson@vistahigherlearning.com>2021-10-16 16:22:08 -0400
commitde833c9d524d2e47b3812612995290795d2e7b84 (patch)
tree707246a8c3324b6b9d16507241a1e00ce2843168 /bonnie-bee/flower.scm
parent58266627bf3ea66dfc6f8434c32304758d1d9e98 (diff)
Allow player to shoot and add flowers to harvest pollen from.
Diffstat (limited to 'bonnie-bee/flower.scm')
-rw-r--r--bonnie-bee/flower.scm37
1 files changed, 37 insertions, 0 deletions
diff --git a/bonnie-bee/flower.scm b/bonnie-bee/flower.scm
new file mode 100644
index 0000000..cafa4f8
--- /dev/null
+++ b/bonnie-bee/flower.scm
@@ -0,0 +1,37 @@
+(define-module (bonnie-bee flower)
+ #:use-module (bonnie-bee actor)
+ #:use-module (bonnie-bee assets)
+ #:use-module (bonnie-bee bullet)
+ #:use-module (chickadee math)
+ #:use-module (chickadee math vector)
+ #:use-module (chickadee scripting)
+ #:use-module (chickadee utils)
+ #:use-module (oop goops)
+ #:use-module (starling node)
+ #:use-module (starling node-2d)
+ #:export (<flower>))
+
+(define-class <flower> (<actor> <damageable>))
+
+(define-method (on-boot (flower <flower>))
+ (attach-to flower
+ (make <sprite>
+ #:texture flower-image
+ #:origin (vec2 32.0 32.0))))
+
+(define-method (on-collide (flower <flower>) (bullet <bullet>))
+ (if (eq? (type bullet) player-primary-bullet)
+ (begin
+ (damage flower 1)
+ (kill-bullet bullet)
+ #t)
+ #f))
+
+(define-method (on-death (flower <flower>) bullets)
+ (let ((p (position flower)))
+ (for-range ((i 16))
+ (let ((theta (- (* (random:uniform) (/ pi -2.0)) (/ pi 4.0)))
+ (speed (+ (* (random:uniform) 1.0) 1.0)))
+ (add-bullet bullets pollen-pickup p
+ (vec2 (* (cos theta) speed)
+ (* (sin theta) speed)))))))