diff options
author | David Thompson <dthompson@vistahigherlearning.com> | 2021-10-20 20:57:28 -0400 |
---|---|---|
committer | David Thompson <dthompson@vistahigherlearning.com> | 2021-10-20 20:57:28 -0400 |
commit | ba887d36cd96e188771eda44ddfb7c31c9811fc0 (patch) | |
tree | 47ccd58137e7fb83251973bd392322417eb252c8 /bonnie-bee | |
parent | 2ea098590c71f240bf26a4174d50cdf69152d7b5 (diff) |
Add placeholder boss battle.
Diffstat (limited to 'bonnie-bee')
-rw-r--r-- | bonnie-bee/assets.scm | 2 | ||||
-rw-r--r-- | bonnie-bee/boss.scm | 40 | ||||
-rw-r--r-- | bonnie-bee/game.scm | 26 |
3 files changed, 61 insertions, 7 deletions
diff --git a/bonnie-bee/assets.scm b/bonnie-bee/assets.scm index 4b41835..3542043 100644 --- a/bonnie-bee/assets.scm +++ b/bonnie-bee/assets.scm @@ -13,6 +13,7 @@ flower-image turret-image moth-image + beetle-image explosion-sound pickup-sound enemy-shoot-sound @@ -38,6 +39,7 @@ (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 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"))) diff --git a/bonnie-bee/boss.scm b/bonnie-bee/boss.scm new file mode 100644 index 0000000..d19f2c2 --- /dev/null +++ b/bonnie-bee/boss.scm @@ -0,0 +1,40 @@ +(define-module (bonnie-bee boss) + #: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 (<boss>)) + +(define-class <boss> (<grounded> <damageable> <actor>)) + +(define-method (on-boot (boss <boss>)) + (attach-to boss + (make <sprite> + #:texture beetle-image + #:origin (vec2 64.0 32.0)))) + +(define-method (on-collide (boss <boss>) (bullet <bullet>)) + (cond + ((player-primary-bullet? bullet) + (damage boss 1) + (kill-bullet bullet) + #t) + ((player-bomb-bullet? bullet) + (damage boss 10) + (kill-bullet bullet)) + (else #f))) + +(define-method (on-death (boss <boss>)) + (audio-play (asset-ref explosion-sound)) + (add-particle-emitter (particles (particles (parent boss))) + (make-particle-emitter (world-hitbox boss) 20 30))) diff --git a/bonnie-bee/game.scm b/bonnie-bee/game.scm index ffdbc3e..b5d1eaf 100644 --- a/bonnie-bee/game.scm +++ b/bonnie-bee/game.scm @@ -2,6 +2,7 @@ #:use-module (bonnie-bee actor) #:use-module (bonnie-bee assets) #:use-module (bonnie-bee background) + #:use-module (bonnie-bee boss) #:use-module (bonnie-bee bullet) #:use-module (bonnie-bee common) #:use-module (bonnie-bee flower) @@ -291,11 +292,6 @@ (sleep 3.0) ;; Wave 2 ;; popcorn that shoots, more flowers - (let loop ((i 0)) - (when (< i 4) - (spawn game - (make-turret (vec2 (random 320) 240))) - (loop (+ i 1)))) ;; Wave 3 ;; turrets, more popcorn, more flowers @@ -305,9 +301,18 @@ ;; intense moths, turrets, popcorn, flowers ;; Boss ;; big beetle thing. no flowers. good luck. - + (tween 1.0 15.0 0.0 + (lambda (speed) + (change-scroll-speed game speed))) + (spawn game (make <boss> + #:name 'boss + #:rank 2 + #:position (vec2 (/ %game-width 2.0) (- %game-height 64.0)) + #:hitbox (make-rect -64.0 -32.0 128.0 64.0) + #:health 100 + #:points 1000000)) ;; Victory - (sleep 5.0) + (wait-until (dead? (& game boss))) (game-complete game) ;; (let loop ((i 0)) @@ -358,6 +363,13 @@ (play-music game intro-music) (change-state game 'game-complete) (stop-scripts game) + (run-script game + (sleep 1.0) + (spawn game (make-flower (vec2 (/ %game-width 4) 160.0))) + (sleep 1.0) + (spawn game (make-flower (vec2 (/ %game-width 2) 160.0))) + (sleep 1.0) + (spawn game (make-flower (vec2 (- %game-width (/ %game-width 4)) 160.0)))) (let ((p (player game))) (stop-scripts p) (set! (shoot? p) #f) |