summaryrefslogtreecommitdiff
path: root/bonnie-bee/player.scm
diff options
context:
space:
mode:
authorDavid Thompson <dthompson@vistahigherlearning.com>2022-10-12 06:48:14 -0400
committerDavid Thompson <dthompson@vistahigherlearning.com>2022-10-27 13:22:50 -0400
commite287a11c4387382277c31735504fc762c33b4cee (patch)
treeb262dc8de64db21a7d2cb2c980f2be39805d6a34 /bonnie-bee/player.scm
parentf713890a773a7d6ff666277592eec72f2328a5b6 (diff)
Switch to Catbird engine.
Diffstat (limited to 'bonnie-bee/player.scm')
-rw-r--r--bonnie-bee/player.scm31
1 files changed, 21 insertions, 10 deletions
diff --git a/bonnie-bee/player.scm b/bonnie-bee/player.scm
index 1a524e7..09770a0 100644
--- a/bonnie-bee/player.scm
+++ b/bonnie-bee/player.scm
@@ -11,17 +11,20 @@
#:use-module (chickadee math vector)
#:use-module (chickadee scripting)
#:use-module (oop goops)
- #:use-module (starling asset)
- #:use-module (starling node)
- #:use-module (starling node-2d)
+ #:use-module (catbird asset)
+ #:use-module (catbird node)
+ #:use-module (catbird node-2d)
#:export (%max-pollen
<player>
move-left?
move-right?
move-down?
move-up?
+ moving?
shoot?
invincible?
+ bombing?
+ scoring-enabled?
speed
lives
pollen
@@ -45,8 +48,15 @@
(invincible? #:accessor invincible? #:init-value #f)
(pollen #:accessor pollen #:init-value 0)
(score #:accessor score #:init-value 0)
+ (scoring-enabled? #:accessor scoring-enabled? #:init-value #f)
(bombing? #:accessor bombing? #:init-value #f))
+(define-method (moving? (player <player>))
+ (or (move-left? player)
+ (move-right? player)
+ (move-down? player)
+ (move-up? player)))
+
(define-method (on-boot (player <player>))
(attach-to player
(make <animated-sprite>
@@ -116,8 +126,8 @@
(set! (lives player) (max (- (lives player) 1) 0))
(set! (pollen player) 0)
(set! (invincible? player) #t)
- (audio-play (asset-ref player-death-sound))
- (add-particle-emitter (particles (particles (parent player)))
+ (audio-play (artifact player-death-sound))
+ (add-particle-emitter (particles (& (parent player) particles))
(make-particle-emitter (world-hitbox player)
10 5))
(run-script player
@@ -127,7 +137,7 @@
(define-method (on-collide (player <player>) (bullet <bullet>))
(cond
((eq? (type bullet) pollen-pickup)
- (audio-play (asset-ref pickup-sound) #:volume 0.3)
+ (audio-play (artifact pickup-sound) #:volume 0.3)
(kill-bullet bullet)
(add-to-score player 5)
(set! (pollen player) (min (+ (pollen player) 1) %max-pollen))
@@ -159,7 +169,7 @@
(shot-interval player)))
(let ((p (position player)))
(set! (last-shot player) (agenda-time))
- (audio-play (asset-ref player-shoot-sound) #:volume 0.2)
+ (audio-play (artifact player-shoot-sound) #:volume 0.2)
(add-bullet bullets
player-primary-bullet
(vec2 (vec2-x p) (+ (vec2-y p) 14.0))
@@ -174,14 +184,14 @@
(radius 16.0)
(speed 5.0)
(p (position player))
- (bullets (bullets (parent player))))
+ (bullets (& (parent player) bullets)))
(add-to-score player (expt 5 times))
(set! (bombing? player) #t)
(set! (pollen player) 0)
(set! (invincible? player) #t)
(let loop ((i 0))
(when (< i times)
- (audio-play (asset-ref player-bomb-sound))
+ (audio-play (artifact player-bomb-sound))
(let shot-loop ((j 0))
(when (< j num-bullets)
(let ((theta (* j theta-step)))
@@ -198,4 +208,5 @@
(set! (bombing? player) #f)))))
(define-method (add-to-score (player <player>) points)
- (set! (score player) (+ (score player) points)))
+ (when (scoring-enabled? player)
+ (set! (score player) (+ (score player) points))))