From ae60497f7722e01ccceebe799b5820717e048eb3 Mon Sep 17 00:00:00 2001 From: David Thompson Date: Wed, 20 Oct 2021 18:42:10 -0400 Subject: Haven't committed in days, oops! --- bonnie-bee/flower.scm | 59 ++++++++++++++++++++++++++++++++++++++------------- 1 file changed, 44 insertions(+), 15 deletions(-) (limited to 'bonnie-bee/flower.scm') diff --git a/bonnie-bee/flower.scm b/bonnie-bee/flower.scm index cafa4f8..2c018e9 100644 --- a/bonnie-bee/flower.scm +++ b/bonnie-bee/flower.scm @@ -2,16 +2,33 @@ #: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 ()) + #:export ( + pollen-enabled? + enable-pollen! + disable-pollen!)) -(define-class ( )) +(define-class ( ) + (emit-pollen? #:allocation #:class #:init-value #f)) + +(define (pollen-enabled?) + (class-slot-ref 'emit-pollen?)) + +(define (enable-pollen!) + (class-slot-set! 'emit-pollen? #t)) + +(define (disable-pollen!) + (class-slot-set! 'emit-pollen? #f)) (define-method (on-boot (flower )) (attach-to flower @@ -20,18 +37,30 @@ #:origin (vec2 32.0 32.0)))) (define-method (on-collide (flower ) (bullet )) - (if (eq? (type bullet) player-primary-bullet) - (begin - (damage flower 1) - (kill-bullet bullet) - #t) - #f)) + (cond + ((player-bullet? bullet) + (damage flower 1) + (kill-bullet bullet) + #t) + ((and (not (pollen-enabled?)) (enemy-bullet? bullet)) + (damage flower 1000) + (kill-bullet bullet)) + (else #f))) -(define-method (on-death (flower ) bullets) +(define-method (on-death (flower )) (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))))))) + (if (pollen-enabled?) + (begin + (audio-play (asset-ref pollen-release-sound)) + (for-range ((i 16)) + (let ((theta (- (* (random:uniform) (/ pi -2.0)) (/ pi 4.0))) + (speed (+ (* (random:uniform) 1.0) 1.0))) + (add-bullet (bullets (parent flower)) + pollen-pickup p + (vec2 (* (cos theta) speed) + (* (sin theta) speed)))))) + (begin + (audio-play (asset-ref explosion-sound)) + (add-particle-emitter (particles (particles (parent flower))) + (make-particle-emitter (make-rect (vec2-x p) (vec2-y p) 1.0 1.0) + 10 5)))))) -- cgit v1.2.3