From 3fc18437f905f18aa4bf3b688930dbc68f8721b3 Mon Sep 17 00:00:00 2001 From: David Thompson Date: Sat, 23 Oct 2021 17:09:34 -0400 Subject: Lots of tweaks and also sprite animations! --- bonnie-bee/flower.scm | 28 +++++++++++++++++++++++----- 1 file changed, 23 insertions(+), 5 deletions(-) (limited to 'bonnie-bee/flower.scm') 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 ( ) (emit-pollen? #:allocation #:class #:init-value #f)) +(define-class ( )) + (define (pollen-enabled?) (class-slot-ref 'emit-pollen?)) @@ -32,9 +34,19 @@ (define-method (on-boot (flower )) (attach-to flower - (make - #:texture flower-image - #:origin (vec2 32.0 32.0)))) + (make + #:atlas flower-atlas + #:origin (vec2 32.0 32.0) + #:animations `((default . ,(make + #:frames #(0 1 0 2) + #:frame-duration .45)))))) + +(define-method (on-boot (flower )) + (attach-to flower + (make + #:atlas flower-atlas + #:origin (vec2 32.0 32.0) + #:index 3))) (define-method (on-collide (flower ) (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 + #: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))) -- cgit v1.2.3