diff options
author | David Thompson <dthompson@vistahigherlearning.com> | 2021-10-20 18:42:10 -0400 |
---|---|---|
committer | David Thompson <dthompson@vistahigherlearning.com> | 2021-10-20 18:42:10 -0400 |
commit | ae60497f7722e01ccceebe799b5820717e048eb3 (patch) | |
tree | 7977b53565d5f1e259d90903213f1add3fefabce /bonnie-bee/turret.scm | |
parent | de833c9d524d2e47b3812612995290795d2e7b84 (diff) |
Haven't committed in days, oops!
Diffstat (limited to 'bonnie-bee/turret.scm')
-rw-r--r-- | bonnie-bee/turret.scm | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/bonnie-bee/turret.scm b/bonnie-bee/turret.scm new file mode 100644 index 0000000..29a3654 --- /dev/null +++ b/bonnie-bee/turret.scm @@ -0,0 +1,49 @@ +(define-module (bonnie-bee turret) + #: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 (<turret>)) + +(define-class <turret> (<grounded> <damageable> <actor>)) + +(define-method (on-boot (turret <turret>)) + (attach-to turret + (make <sprite> + #:texture turret-image + #:origin (vec2 32.0 32.0)))) + +(define-method (on-collide (turret <turret>) (bullet <bullet>)) + (cond + ((player-primary-bullet? bullet) + (damage turret 1) + (kill-bullet bullet) + #t) + ((player-bomb-bullet? bullet) + (damage turret 10) + (kill-bullet bullet)) + (else #f))) + +(define-method (on-death (turret <turret>)) + (audio-play (asset-ref explosion-sound)) + (let ((p (position turret))) + (add-particle-emitter (particles (particles (parent turret))) + (make-particle-emitter (make-rect (vec2-x p) (vec2-y p) 1.0 1.0) + 10 3)) + (for-range ((i 8)) + (let ((theta (- (* (random:uniform) (/ pi -2.0)) (/ pi 4.0))) + (speed (+ (* (random:uniform) 1.0) 1.0))) + (add-bullet (bullets (parent turret)) + medium-enemy-bullet p + (vec2 (* (cos theta) speed) + (* (sin theta) speed))))))) |