diff options
author | David Thompson <dthompson@vistahigherlearning.com> | 2021-10-23 17:09:34 -0400 |
---|---|---|
committer | David Thompson <dthompson@vistahigherlearning.com> | 2021-10-23 17:09:34 -0400 |
commit | 3fc18437f905f18aa4bf3b688930dbc68f8721b3 (patch) | |
tree | e14a25532309c88e2a33d5a7641f381a69733966 /bonnie-bee/flower.scm | |
parent | fb31282c18f33acb6de24e604059df6d05477491 (diff) |
Lots of tweaks and also sprite animations!
Diffstat (limited to 'bonnie-bee/flower.scm')
-rw-r--r-- | bonnie-bee/flower.scm | 28 |
1 files changed, 23 insertions, 5 deletions
diff --git a/bonnie-bee/flower.scm b/bonnie-bee/flower.scm index 13d8c10..5e9eb12 100644 --- a/bonnie-bee/flower.scm +++ b/bonnie-bee/flower.scm @@ -21,6 +21,8 @@ (define-class <flower> (<grounded> <damageable> <actor>) (emit-pollen? #:allocation #:class #:init-value #f)) +(define-class <pollinated-flower> (<grounded> <actor>)) + (define (pollen-enabled?) (class-slot-ref <flower> 'emit-pollen?)) @@ -32,9 +34,19 @@ (define-method (on-boot (flower <flower>)) (attach-to flower - (make <sprite> - #:texture flower-image - #:origin (vec2 32.0 32.0)))) + (make <animated-sprite> + #:atlas flower-atlas + #:origin (vec2 32.0 32.0) + #:animations `((default . ,(make <animation> + #:frames #(0 1 0 2) + #:frame-duration .45)))))) + +(define-method (on-boot (flower <pollinated-flower>)) + (attach-to flower + (make <atlas-sprite> + #:atlas flower-atlas + #:origin (vec2 32.0 32.0) + #:index 3))) (define-method (on-collide (flower <flower>) (bullet <bullet>)) (cond @@ -56,12 +68,18 @@ (begin (audio-play (asset-ref pollen-release-sound)) (for-range ((i 16)) - (let ((theta (- (* (random:uniform) (/ pi -2.0)) (/ pi 4.0))) + (let ((theta (- (* (- (random:uniform) 0.5) (/ pi 3.0)) + (/ pi 2.0))) (speed (+ (* (random:uniform) 1.0) 1.0))) (add-bullet (bullets (parent flower)) pollen-pickup p (vec2 (* (cos theta) speed) - (* (sin theta) speed)))))) + (* (sin theta) speed))))) + (spawn (parent flower) + (make <pollinated-flower> + #:rank 1 + #:position (position flower) + #:hitbox (make-rect -1.0 -1.0 2.0 2.0)))) (begin (audio-play (asset-ref explosion-sound)) (add-particle-emitter (particles (particles (parent flower))) |