From e287a11c4387382277c31735504fc762c33b4cee Mon Sep 17 00:00:00 2001 From: David Thompson Date: Wed, 12 Oct 2022 06:48:14 -0400 Subject: Switch to Catbird engine. --- bonnie-bee/player.scm | 31 +++++++++++++++++++++---------- 1 file changed, 21 insertions(+), 10 deletions(-) (limited to 'bonnie-bee/player.scm') 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 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 )) + (or (move-left? player) + (move-right? player) + (move-down? player) + (move-up? player))) + (define-method (on-boot (player )) (attach-to player (make @@ -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 ) (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 ) points) - (set! (score player) (+ (score player) points))) + (when (scoring-enabled? player) + (set! (score player) (+ (score player) points)))) -- cgit v1.2.3