diff options
-rw-r--r-- | assets/images/bee.png | bin | 2678 -> 2530 bytes | |||
-rw-r--r-- | assets/images/bee.xcf | bin | 7186 -> 12500 bytes | |||
-rw-r--r-- | assets/images/beetle.png | bin | 2662 -> 3764 bytes | |||
-rw-r--r-- | assets/images/beetle.xcf | bin | 21364 -> 31865 bytes | |||
-rw-r--r-- | assets/images/darkness.png | bin | 0 -> 1186 bytes | |||
-rw-r--r-- | assets/images/flower-turret.png | bin | 1488 -> 0 bytes | |||
-rw-r--r-- | assets/images/flower-turret.xcf | bin | 4387 -> 0 bytes | |||
-rw-r--r-- | assets/images/flower.png | bin | 1433 -> 2010 bytes | |||
-rw-r--r-- | assets/images/flower.xcf | bin | 3877 -> 20082 bytes | |||
-rw-r--r-- | assets/images/moth.png | bin | 1356 -> 2385 bytes | |||
-rw-r--r-- | assets/images/moth.xcf | bin | 6628 -> 12515 bytes | |||
-rw-r--r-- | assets/images/particle.png | bin | 623 -> 653 bytes | |||
-rw-r--r-- | assets/images/particle.xcf | bin | 874 -> 1025 bytes | |||
-rw-r--r-- | assets/images/popcorn.png | bin | 862 -> 1064 bytes | |||
-rw-r--r-- | assets/images/popcorn.xcf | bin | 1760 -> 2857 bytes | |||
-rw-r--r-- | assets/images/turret.png | bin | 0 -> 3263 bytes | |||
-rw-r--r-- | assets/images/turret.xcf | bin | 0 -> 17765 bytes | |||
-rw-r--r-- | assets/sounds/enemy-shoot.wav | bin | 8672 -> 11502 bytes | |||
-rw-r--r-- | assets/sounds/hehehe.wav | bin | 0 -> 150956 bytes | |||
-rw-r--r-- | bonnie-bee/actor.scm | 4 | ||||
-rw-r--r-- | bonnie-bee/assets.scm | 24 | ||||
-rw-r--r-- | bonnie-bee/boss.scm | 11 | ||||
-rw-r--r-- | bonnie-bee/bullet.scm | 2 | ||||
-rw-r--r-- | bonnie-bee/common.scm | 27 | ||||
-rw-r--r-- | bonnie-bee/flower.scm | 28 | ||||
-rw-r--r-- | bonnie-bee/game.scm | 96 | ||||
-rw-r--r-- | bonnie-bee/moth.scm | 9 | ||||
-rw-r--r-- | bonnie-bee/player.scm | 39 | ||||
-rw-r--r-- | bonnie-bee/popcorn.scm | 9 | ||||
-rw-r--r-- | bonnie-bee/splash.scm | 32 | ||||
-rw-r--r-- | bonnie-bee/turret.scm | 9 |
31 files changed, 205 insertions, 85 deletions
diff --git a/assets/images/bee.png b/assets/images/bee.png Binary files differindex 7fec5ef..330aadb 100644 --- a/assets/images/bee.png +++ b/assets/images/bee.png diff --git a/assets/images/bee.xcf b/assets/images/bee.xcf Binary files differindex e533a59..3a56131 100644 --- a/assets/images/bee.xcf +++ b/assets/images/bee.xcf diff --git a/assets/images/beetle.png b/assets/images/beetle.png Binary files differindex 2544efd..76785fc 100644 --- a/assets/images/beetle.png +++ b/assets/images/beetle.png diff --git a/assets/images/beetle.xcf b/assets/images/beetle.xcf Binary files differindex a23c50d..59a2773 100644 --- a/assets/images/beetle.xcf +++ b/assets/images/beetle.xcf diff --git a/assets/images/darkness.png b/assets/images/darkness.png Binary files differnew file mode 100644 index 0000000..6c30259 --- /dev/null +++ b/assets/images/darkness.png diff --git a/assets/images/flower-turret.png b/assets/images/flower-turret.png Binary files differdeleted file mode 100644 index 86e40ca..0000000 --- a/assets/images/flower-turret.png +++ /dev/null diff --git a/assets/images/flower-turret.xcf b/assets/images/flower-turret.xcf Binary files differdeleted file mode 100644 index 65ef52b..0000000 --- a/assets/images/flower-turret.xcf +++ /dev/null diff --git a/assets/images/flower.png b/assets/images/flower.png Binary files differindex f0d35c6..e9f4d5b 100644 --- a/assets/images/flower.png +++ b/assets/images/flower.png diff --git a/assets/images/flower.xcf b/assets/images/flower.xcf Binary files differindex 8b43df9..24c7e46 100644 --- a/assets/images/flower.xcf +++ b/assets/images/flower.xcf diff --git a/assets/images/moth.png b/assets/images/moth.png Binary files differindex 47074ba..d568203 100644 --- a/assets/images/moth.png +++ b/assets/images/moth.png diff --git a/assets/images/moth.xcf b/assets/images/moth.xcf Binary files differindex 988c903..a7c19ab 100644 --- a/assets/images/moth.xcf +++ b/assets/images/moth.xcf diff --git a/assets/images/particle.png b/assets/images/particle.png Binary files differindex 0d55a93..f3fba79 100644 --- a/assets/images/particle.png +++ b/assets/images/particle.png diff --git a/assets/images/particle.xcf b/assets/images/particle.xcf Binary files differindex 66da7fc..90e49d4 100644 --- a/assets/images/particle.xcf +++ b/assets/images/particle.xcf diff --git a/assets/images/popcorn.png b/assets/images/popcorn.png Binary files differindex d35cfce..7a5b01a 100644 --- a/assets/images/popcorn.png +++ b/assets/images/popcorn.png diff --git a/assets/images/popcorn.xcf b/assets/images/popcorn.xcf Binary files differindex b765b71..a240f0c 100644 --- a/assets/images/popcorn.xcf +++ b/assets/images/popcorn.xcf diff --git a/assets/images/turret.png b/assets/images/turret.png Binary files differnew file mode 100644 index 0000000..41ab670 --- /dev/null +++ b/assets/images/turret.png diff --git a/assets/images/turret.xcf b/assets/images/turret.xcf Binary files differnew file mode 100644 index 0000000..bf83d6d --- /dev/null +++ b/assets/images/turret.xcf diff --git a/assets/sounds/enemy-shoot.wav b/assets/sounds/enemy-shoot.wav Binary files differindex a49c17e..56d5a91 100644 --- a/assets/sounds/enemy-shoot.wav +++ b/assets/sounds/enemy-shoot.wav diff --git a/assets/sounds/hehehe.wav b/assets/sounds/hehehe.wav Binary files differnew file mode 100644 index 0000000..6ea2bb0 --- /dev/null +++ b/assets/sounds/hehehe.wav diff --git a/bonnie-bee/actor.scm b/bonnie-bee/actor.scm index 90938c8..8aec98a 100644 --- a/bonnie-bee/actor.scm +++ b/bonnie-bee/actor.scm @@ -29,7 +29,8 @@ <grounded> player bullets - scroll-speed)) + scroll-speed + spawn)) (define-class <actor> (<node-2d>) (velocity #:getter velocity #:init-keyword #:velocity #:init-form (vec2 0.0 0.0)) @@ -149,3 +150,4 @@ (define-generic player) (define-generic bullets) +(define-generic spawn) diff --git a/bonnie-bee/assets.scm b/bonnie-bee/assets.scm index 3542043..7c96307 100644 --- a/bonnie-bee/assets.scm +++ b/bonnie-bee/assets.scm @@ -7,13 +7,14 @@ monogram-font background-image particle-image + darkness-image bee-atlas bullet-atlas - popcorn-image - flower-image - turret-image - moth-image - beetle-image + popcorn-atlas + flower-atlas + turret-atlas + moth-atlas + beetle-atlas explosion-sound pickup-sound enemy-shoot-sound @@ -22,6 +23,7 @@ player-shoot-sound player-bomb-sound pollen-release-sound + hehehe-sound intro-music main-music)) @@ -33,13 +35,14 @@ (define-asset monogram-font (load-font (scope-datadir "assets/fonts/monogram_extended.ttf") 12)) (define-asset background-image (load-image (scope-datadir "assets/images/background.png"))) (define-asset particle-image (load-image (scope-datadir "assets/images/particle.png"))) +(define-asset darkness-image (load-image (scope-datadir "assets/images/darkness.png"))) (define-asset bee-atlas (load-tileset (scope-datadir "assets/images/bee.png") 32 32)) (define-asset bullet-atlas (load-tileset (scope-datadir "assets/images/bullets.png") 16 16)) -(define-asset flower-image (load-image (scope-datadir "assets/images/flower.png"))) -(define-asset popcorn-image (load-image (scope-datadir "assets/images/popcorn.png"))) -(define-asset turret-image (load-image (scope-datadir "assets/images/flower-turret.png"))) -(define-asset moth-image (load-image (scope-datadir "assets/images/moth.png"))) -(define-asset beetle-image (load-image (scope-datadir "assets/images/beetle.png"))) +(define-asset flower-atlas (load-tileset (scope-datadir "assets/images/flower.png") 64 64)) +(define-asset popcorn-atlas (load-tileset (scope-datadir "assets/images/popcorn.png") 32 32)) +(define-asset turret-atlas (load-tileset (scope-datadir "assets/images/turret.png") 64 64)) +(define-asset moth-atlas (load-tileset (scope-datadir "assets/images/moth.png") 64 64)) +(define-asset beetle-atlas (load-tileset (scope-datadir "assets/images/beetle.png") 128 64)) (define-asset explosion-sound (load-audio (scope-datadir "assets/sounds/explosion.wav"))) (define-asset pickup-sound (load-audio (scope-datadir "assets/sounds/pickup.wav"))) (define-asset enemy-shoot-sound (load-audio (scope-datadir "assets/sounds/enemy-shoot.wav"))) @@ -48,5 +51,6 @@ (define-asset player-shoot-sound (load-audio (scope-datadir "assets/sounds/player-shoot.wav"))) (define-asset player-bomb-sound (load-audio (scope-datadir "assets/sounds/player-bomb.wav"))) (define-asset pollen-release-sound (load-audio (scope-datadir "assets/sounds/pollen-release.wav"))) +(define-asset hehehe-sound (load-audio (scope-datadir "assets/sounds/hehehe.wav"))) (define-asset intro-music (load-audio (scope-datadir "assets/sounds/intro.ogg") #:mode 'stream)) (define-asset main-music (load-audio (scope-datadir "assets/sounds/main.ogg") #:mode 'stream)) diff --git a/bonnie-bee/boss.scm b/bonnie-bee/boss.scm index 885f0bc..e312d4e 100644 --- a/bonnie-bee/boss.scm +++ b/bonnie-bee/boss.scm @@ -21,9 +21,12 @@ (define-method (on-boot (boss <boss>)) (attach-to boss - (make <sprite> - #:texture beetle-image - #:origin (vec2 64.0 32.0)))) + (make <animated-sprite> + #:atlas beetle-atlas + #:origin (vec2 64.0 32.0) + #:animations `((default . ,(make <animation> + #:frames #(0 1) + #:frame-duration 0.4)))))) (define-method (on-enter (boss <boss>)) (define (circle-shot n offset speed type) @@ -51,13 +54,13 @@ (little-speed 1.0)) (while (> (health boss) 800) (let ((d (direction-to boss (player (parent boss))))) + (audio-play (asset-ref enemy-shoot-sound)) (add-bullet (bullets (parent boss)) large-enemy-bullet (position boss) (vec2* d big-speed)) (let loop ((i 0)) (when (< i 16) - (audio-play (asset-ref enemy-shoot-sound)) (random-shot little-speed) (sleep (* (current-timestep) 2.0)) (loop (+ i 1))))))) diff --git a/bonnie-bee/bullet.scm b/bonnie-bee/bullet.scm index 1ec40b5..758ff5a 100644 --- a/bonnie-bee/bullet.scm +++ b/bonnie-bee/bullet.scm @@ -202,7 +202,7 @@ (< (rect-left h) -16.0) (> (rect-right h) 336.0) (< (rect-bottom h) -16.0) - (> (rect-top h) 256.0)) + (> (rect-top h) 272.0)) (remove-bullet bullets i) (loop i)) ((and (= (vec2-x v) 0.0) diff --git a/bonnie-bee/common.scm b/bonnie-bee/common.scm index 75a6bc4..885ab33 100644 --- a/bonnie-bee/common.scm +++ b/bonnie-bee/common.scm @@ -1,17 +1,22 @@ (define-module (bonnie-bee common) + #:use-module (bonnie-bee assets) #:use-module (chickadee game-loop) #:use-module (chickadee graphics color) #:use-module (chickadee graphics viewport) #:use-module (chickadee math vector) + #:use-module (chickadee scripting) #:use-module (oop goops) #:use-module (starling scene) + #:use-module (starling node) #:use-module (starling node-2d) #:export (%window-width %window-height %game-width %game-height set-cameras! - steps)) + steps + fade-in + fade-out)) (define %window-width 960) (define %window-height 720) @@ -27,3 +32,23 @@ (define (steps n) (* n (current-timestep))) + +(define-method (fade-in (scene <scene-2d>) duration) + (let ((bg (make <sprite> + #:rank 999 + #:texture darkness-image))) + (attach-to scene bg) + (tween duration 1.0 0.0 + (lambda (a) + (set! (tint bg) (transparency a)))) + (detach bg))) + +(define-method (fade-out (scene <scene-2d>) duration) + (let ((bg (make <sprite> + #:rank 999 + #:texture darkness-image))) + (attach-to scene bg) + (tween duration 0.0 1.0 + (lambda (a) + (set! (tint bg) (transparency a)))) + (detach bg))) 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))) diff --git a/bonnie-bee/game.scm b/bonnie-bee/game.scm index feb395e..b868cd2 100644 --- a/bonnie-bee/game.scm +++ b/bonnie-bee/game.scm @@ -85,7 +85,9 @@ #:texture background-image) (make <particles> #:name 'particles - #:particles (make-particles 2048 #:texture (asset-ref particle-image))) + #:particles (make-particles 2048 + #:texture (asset-ref particle-image) + #:end-color (make-color 1.0 1.0 1.0 0.0))) (make <bullets> #:name 'bullets #:rank 3 @@ -185,18 +187,20 @@ (sleep 2.0)) (detach l))) (run-script game + (fade-in game 1.0)) + (run-script game (unless (getenv "SKIP_INTRO") ;; Intro (let ((popcorn (make-popcorn (vec2 (/ %game-width 2.0) (+ %game-height 16.0)))) (bullet-speed 5.0) - (flower-1 (make-flower (vec2 174.0 227.0))) - (flower-2 (make-flower (vec2 50.0 226.0))) + (flower-1 (make-flower (vec2 194.0 210.0))) + (flower-2 (make-flower (vec2 50.0 206.0))) (flower-3 (make-flower (vec2 280.0 201.0))) (flower-4 (make-flower (vec2 121.0 197.0))) - (flower-5 (make-flower (vec2 54.0 134.0))) - (flower-6 (make-flower (vec2 150.0 121.0))) - (flower-7 (make-flower (vec2 256.0 131.0))) - (flower-8 (make-flower (vec2 307.0 109.0)))) + (flower-5 (make-flower (vec2 58.0 134.0))) + (flower-6 (make-flower (vec2 145.0 135.0))) + (flower-7 (make-flower (vec2 220.0 151.0))) + (flower-8 (make-flower (vec2 290.0 129.0)))) (define (shoot-at flower) (audio-play (asset-ref enemy-shoot-sound)) (add-bullet (bullets game) @@ -204,7 +208,6 @@ (position popcorn) (vec2* (direction-to popcorn flower) bullet-speed))) (change-state game 'intro) - (play-music game intro-music) (spawn game flower-1) (spawn game flower-2) (spawn game flower-3) @@ -214,13 +217,13 @@ (spawn game flower-7) (spawn game flower-8) (spawn game (make-flower (vec2 194.0 95.0))) - (spawn game (make-flower (vec2 102.0 76.0))) - (spawn game (make-flower (vec2 26.0 58.0))) + (spawn game (make-flower (vec2 102.0 82.0))) (spawn game (make-flower (vec2 247.0 45.0))) - (spawn game (make-flower (vec2 169.0 12.0))) - (spawn game (make-flower (vec2 53.0 7.0))) - (teleport (player game) 169.0 12.0) - (sleep 0.6) + (spawn game (make-flower (vec2 159.0 40.0))) + (spawn game (make-flower (vec2 73.0 28.0))) + (teleport (player game) 159.0 40.0) + (play-music game intro-music) + (sleep 1.0) (audio-play (asset-ref pollen-release-sound)) (sleep 0.6) (move-to (player game) 247.0 45.0 1.0) @@ -238,8 +241,9 @@ (source-stop (music-source game)) (spawn game popcorn) (change-velocity popcorn 0.0 -1.0) - (sleep 1.5) - (change-velocity popcorn 0.0 0.0) + (tween 2.4 -1.0 0.0 + (lambda (dy) + (change-velocity popcorn 0.0 dy))) (shoot-at flower-1) (sleep 0.3) (shoot-at flower-2) @@ -248,15 +252,19 @@ (sleep 0.3) (shoot-at flower-4) (sleep 0.3) - (shoot-at flower-5) - (sleep 0.3) - (shoot-at flower-6) + (shoot-at flower-8) (sleep 0.3) (shoot-at flower-7) (sleep 0.3) - (shoot-at flower-8) - (sleep 2.0) - (change-velocity popcorn 0.0 1.5) + (shoot-at flower-6) + (sleep 0.3) + (shoot-at flower-5) + (sleep 1.0) + (audio-play (asset-ref hehehe-sound)) + (sleep 1.0) + (tween 0.5 0.0 1.5 + (lambda (dy) + (change-velocity popcorn 0.0 dy))) (sleep 1.0))) (enable-pollen!) (change-state game 'play) @@ -318,7 +326,6 @@ (vec2 -2.0 2.0) 0.2) (sleep 3.0)) ;; Wave 2 - ;; kamikaze popcorn, turrets, more flowers (define (spawn-turret x) (spawn game (make-turret (vec2 x (+ %game-height 32.0))))) (define (shoot-down enemy) @@ -393,9 +400,16 @@ (spawn-flower 153.0) (sleep 1.0) (spawn-turret 209.0) + (sleep 1.0) (popcorn-line 10 (vec2 (+ %game-width 16.0) 200.0) (vec2 -3.0 -0.5) 0.2) - (sleep 8.0) + (sleep 1.0) + (popcorn-line 10 (vec2 -16.0 200.0) + (vec2 3.0 -0.5) 0.2) + (sleep 1.0) + (popcorn-line 10 (vec2 (+ %game-width 16.0) 200.0) + (vec2 -3.0 -0.5) 0.2) + (sleep 1.0) (run-script game (spawn-turret (* %game-width 0.25)) (sleep 2.0) @@ -408,7 +422,8 @@ (spawn-turret (* %game-width 0.25))) (repeat 100 (let ((popcorn (make-popcorn (vec2 (+ (/ %game-width 2.0) - (* (/ %game-width 4.0) (- (random:uniform) 0.5))) + (* (/ %game-width 4.0) + (- (random:uniform) 0.5))) (+ %game-height 16.0)) (vec2 0.0 -2.0)))) (spawn game popcorn) @@ -424,7 +439,6 @@ (sleep 0.1)) (sleep 8.0)) ;; Wave 3 - ;; moths, more turrets, more flowers (define (spawn-moth p) (let ((moth (make-moth p))) (spawn game moth) @@ -490,23 +504,21 @@ (spawn-moth (vec2 (* %game-width 0.25) (+ %game-height 16.0))) (spawn-moth (vec2 (* %game-width 0.5) (+ %game-height 16.0))) (spawn-moth (vec2 (* %game-width 0.75) (+ %game-height 16.0))) - (sleep 6.0)) + (sleep 14.0)) ;; Boss - (tween 1.0 15.0 0.0 - (lambda (speed) - (change-scroll-speed game speed))) (unless (getenv "SKIP_BOSS") - (let ((boss (make <boss> + (spawn game (make <boss> #:name 'boss #:rank 2 - #:position (vec2 (/ %game-width 2.0) (+ %game-height 32.0)) + #:position (vec2 (/ %game-width 2.0) + (+ %game-height 32.0)) #:hitbox (make-rect -64.0 -32.0 128.0 64.0) #:health 1200 - #:points 100000))) - (spawn game boss) - (change-velocity boss 0.0 -1.0) - (sleep 1.4) - (change-velocity boss 0.0 0.0)) + #:points 100000)) + (sleep 4.5) + (tween 1.0 15.0 0.0 + (lambda (speed) + (change-scroll-speed game speed))) (wait-until (dead? (& game boss)))) ;; Victory! (set! (invincible? (player game)) #t) @@ -538,7 +550,6 @@ (reset-game game)) (define-method (game-complete (game <game>)) - (hide (& game hud-lives)) (hide (& game hud-pollen)) (tween 1.0 1.0 0.0 (lambda (volume) @@ -647,7 +658,14 @@ ((q) (pop-scene (current-kernel))) ((return) - (reset-game game)))) + (run-script game + (tween 1.0 1.0 0.0 + (lambda (volume) + (set-source-volume! (music-source game) volume))) + (source-stop (music-source game))) + (run-script game + (fade-out game 1.0) + (reset-game game))))) ((intro) (case key ((q) diff --git a/bonnie-bee/moth.scm b/bonnie-bee/moth.scm index 8f4ed5f..bcd165b 100644 --- a/bonnie-bee/moth.scm +++ b/bonnie-bee/moth.scm @@ -19,9 +19,12 @@ (define-method (on-boot (moth <moth>)) (attach-to moth - (make <sprite> - #:texture moth-image - #:origin (vec2 32.0 32.0)))) + (make <animated-sprite> + #:atlas moth-atlas + #:origin (vec2 32.0 32.0) + #:animations `((default . ,(make <animation> + #:frames #(0 1 0 2) + #:frame-duration .1)))))) (define-method (on-collide (moth <moth>) (bullet <bullet>)) (cond diff --git a/bonnie-bee/player.scm b/bonnie-bee/player.scm index 0d7f1e0..f990657 100644 --- a/bonnie-bee/player.scm +++ b/bonnie-bee/player.scm @@ -32,8 +32,8 @@ (define %max-pollen 50) (define-class <player> (<actor>) - (move-left? #:accessor move-left? #:init-value #f) - (move-right? #:accessor move-right? #:init-value #f) + (move-left? #:accessor move-left? #:init-value #f #:watch? #t) + (move-right? #:accessor move-right? #:init-value #f #:watch? #t) (move-down? #:accessor move-down? #:init-value #f) (move-up? #:accessor move-up? #:init-value #f) (shoot? #:accessor shoot? #:init-value #f #:watch? #t) @@ -48,16 +48,43 @@ (define-method (on-boot (player <player>)) (attach-to player - (make <atlas-sprite> + (make <animated-sprite> + #:name 'sprite #:atlas bee-atlas - #:index 12 - #:origin (vec2 16.0 16.0)))) + #:origin (vec2 16.0 16.0) + #:animations `((default . ,(make <animation> + #:frames #(0 1) + #:frame-duration 0.05)) + (move-left . ,(make <animation> + #:frames #(2 3) + #:frame-duration 0.05)) + (move-right . ,(make <animation> + #:frames #(4 5) + #:frame-duration 0.05)) + (idle . ,(make <animation> + #:frames #(0 1) + #:frame-duration 0.75)))))) + +(define-method (update-animation (player <player>)) + (change-animation (& player sprite) + (cond + ((and (move-left? player) + (not (move-right? player))) + 'move-left) + ((and (not (move-left? player)) + (move-right? player)) + 'move-right) + (else + 'default)))) (define-method (on-change (player <player>) slot-name old new) (case slot-name ((shoot?) (when (and new (not (and old new))) - (set! (last-shot player) 0))))) + (set! (last-shot player) 0))) + ((move-left? move-right?) + (unless (eq? old new) + (update-animation player))))) (define-method (after-move (player <player>)) (let ((p (position player))) diff --git a/bonnie-bee/popcorn.scm b/bonnie-bee/popcorn.scm index 8c70326..594e88c 100644 --- a/bonnie-bee/popcorn.scm +++ b/bonnie-bee/popcorn.scm @@ -19,9 +19,12 @@ (define-method (on-boot (popcorn <popcorn>)) (attach-to popcorn - (make <sprite> - #:texture popcorn-image - #:origin (vec2 16.0 16.0)))) + (make <animated-sprite> + #:atlas popcorn-atlas + #:origin (vec2 16.0 16.0) + #:animations `((default . ,(make <animation> + #:frames #(0 1) + #:frame-duration .25)))))) (define-method (on-collide (popcorn <popcorn>) (bullet <bullet>)) (if (player-bullet? bullet) diff --git a/bonnie-bee/splash.scm b/bonnie-bee/splash.scm index 3b8fba6..98239d6 100644 --- a/bonnie-bee/splash.scm +++ b/bonnie-bee/splash.scm @@ -14,23 +14,37 @@ (define-class <splash> (<scene-2d>)) +(define %text-color (rgb #xfee761)) + (define-method (on-boot (splash <splash>)) (set-cameras! splash) (attach-to splash + (make <sprite> + #:texture darkness-image) + (make <label> + #:rank 1 + #:position (vec2 (/ %game-width 2.0) 120.0) + #:font monogram-font + #:color %text-color + #:align 'center + #:vertical-align 'center + #:text "Made with Chickadee") (make <label> - #:name 'label - #:font chonkly-font - #:color black + #:rank 1 + #:position (vec2 (/ %game-width 2.0) 100.0) + #:font monogram-font + #:color %text-color #:align 'center #:vertical-align 'center - #:position (vec2 (/ %game-width 2.0) (/ %game-height 2.0))))) + #:text "https://dthompson.us/projects/chickadee.html"))) (define-method (on-enter (splash <splash>)) - (unless (getenv "SKIP_SPLASH") - (run-script splash - (set! (text (& splash label)) "made with chickadee") - (sleep 0.5) - (replace-scene (current-kernel) (make <game>))))) + (run-script splash + (unless (getenv "SKIP_SPLASH") + (fade-in splash 1.0) + (sleep 1.0) + (fade-out splash 1.0)) + (replace-scene (current-kernel) (make <game>)))) (define (launch-game) (boot-kernel (make <kernel> diff --git a/bonnie-bee/turret.scm b/bonnie-bee/turret.scm index 9474c65..5aae796 100644 --- a/bonnie-bee/turret.scm +++ b/bonnie-bee/turret.scm @@ -19,9 +19,12 @@ (define-method (on-boot (turret <turret>)) (attach-to turret - (make <sprite> - #:texture turret-image - #:origin (vec2 32.0 32.0)))) + (make <animated-sprite> + #:atlas turret-atlas + #:origin (vec2 32.0 32.0) + #:animations `((default . ,(make <animation> + #:frames #(0 1 2 3) + #:frame-duration .15)))))) (define-method (on-collide (turret <turret>) (bullet <bullet>)) (cond |