summaryrefslogtreecommitdiff
path: root/super-bloom
diff options
context:
space:
mode:
authorDavid Thompson <dthompson2@worcester.edu>2023-06-04 10:55:00 -0400
committerDavid Thompson <dthompson2@worcester.edu>2023-06-04 10:55:00 -0400
commitfeed38794b0209d4defc3b7f110043b5ec86e92f (patch)
tree103f58337ed28167d205dd47bb2a1ab3a2167844 /super-bloom
parent45791c1360c98957ebe27655d59a2ae9db6cd709 (diff)
An attempt to make things somewhat playable.
Diffstat (limited to 'super-bloom')
-rw-r--r--super-bloom/dirt-ball.scm5
-rw-r--r--super-bloom/flower.scm31
-rw-r--r--super-bloom/game.scm138
-rw-r--r--super-bloom/player.scm2
4 files changed, 147 insertions, 29 deletions
diff --git a/super-bloom/dirt-ball.scm b/super-bloom/dirt-ball.scm
index fd86d5b..43c8d4c 100644
--- a/super-bloom/dirt-ball.scm
+++ b/super-bloom/dirt-ball.scm
@@ -28,7 +28,8 @@
#:use-module (super-bloom common)
#:use-module (super-bloom flower)
#:use-module (super-bloom water)
- #:export (<dirt-ball>))
+ #:export (<dirt-ball>
+ dead?))
(define-asset (dirt-ball-tileset (file (scope-datadir "assets/images/dirt-ball.png")))
(load-tileset file 32 32))
@@ -67,7 +68,7 @@
(set! (dead? dirt-ball) #t))
(define-method (on-collide (dirt-ball <dirt-ball>) (flower <flower>))
- (damage flower 5)
+ (damage flower 2)
(set! (dead? dirt-ball) #t))
(define-method (update (dirt-ball <dirt-ball>) _dt)
diff --git a/super-bloom/flower.scm b/super-bloom/flower.scm
index 428b158..78e8f03 100644
--- a/super-bloom/flower.scm
+++ b/super-bloom/flower.scm
@@ -75,6 +75,11 @@
#:name 'progress-meter
#:position (vec2 -32.0 -28.0)
#:width 64.0
+ #:height 8.0)
+ (make <canvas>
+ #:name 'idle-meter
+ #:position (vec2 -32.0 -36.0)
+ #:width 64.0
#:height 8.0))
(update-progress-meter flower))
@@ -95,6 +100,28 @@
(default-width (& flower progress-meter))
(default-height (& flower progress-meter))))
+(define-method (update-idle-meter (flower <flower>))
+ (define w 64.0)
+ (define t (- 1.0 (/ (growth-accumulator flower) (growth-interval flower))))
+ (define meter (& flower idle-meter))
+ (if (>= t 0.999)
+ (hide meter)
+ (begin
+ (show meter)
+ (set! (painter meter)
+ (superimpose
+ (with-style ((stroke-color (make-color 0.0 0.0 0.0 0.5))
+ (stroke-width 2.0))
+ (stroke
+ (line (vec2 0.0 0.0) (vec2 w 0.0))))
+ (with-style ((stroke-color db32-mandy)
+ (stroke-width 2.0))
+ (stroke
+ (line (vec2 0.0 0.0) (vec2 (* w t) 0.0))))))
+ (resize meter
+ (default-width meter)
+ (default-height meter)))))
+
(define-method (update-animation (flower <flower>))
(define t (/ (growth-progress flower) (growth-goal flower)))
@@ -128,6 +155,7 @@
(audio-play (artifact watered-sound))))
(define-method (update (flower <flower>) dt)
+ (update-idle-meter flower)
(unless (thirsty? flower)
(let ((interval (growth-interval flower))
(accum (+ (growth-accumulator flower) dt)))
@@ -136,8 +164,7 @@
(set! (growth-progress flower)
(min (+ (growth-progress flower) 1)
(growth-goal flower)))
- (set! (growth-accumulator flower)
- (if (thirsty? flower) 0 (- accum interval)))
+ (set! (growth-accumulator flower) 0.0)
(decrement-water flower 1)
(update-animation flower)
(update-progress-meter flower))))
diff --git a/super-bloom/game.scm b/super-bloom/game.scm
index f5f1d99..9d0dbeb 100644
--- a/super-bloom/game.scm
+++ b/super-bloom/game.scm
@@ -28,6 +28,7 @@
#:use-module (chickadee graphics texture)
#:use-module (chickadee math rect)
#:use-module (chickadee math vector)
+ #:use-module (chickadee scripting)
#:use-module (oop goops)
#:use-module (super-bloom actor)
#:use-module (super-bloom common)
@@ -117,8 +118,108 @@
#:position (vec2 (/ %game-width:float 2.0)
(/ %game-height:float 2.0))
#:quadtree (quadtree mode)
- #:growth-goal 10
- #:growth-interval 0.5))))
+ #:growth-goal 20
+ #:growth-interval 3.0))
+ (start-game mode)))
+
+(define-method (spawn-water (mode <super-bloom-mode>) position)
+ (attach-to (parent mode)
+ (make <water>
+ #:rank 3
+ #:position position
+ #:quadtree (quadtree mode))))
+
+(define-method (spawn-dirt-ball (mode <super-bloom-mode>) position)
+ (attach-to (parent mode)
+ (make <dirt-ball>
+ #:rank 3
+ #:position position
+ #:quadtree (quadtree mode)
+ #:flower (& (parent mode) flower)
+ #:speed 1.0
+ #:explosion-particles (& (parent mode) explosion-particles))))
+
+(define-method (spawn-random-water (mode <super-bloom-mode>))
+ (spawn-water mode (vec2 (random:float %game-width:float)
+ (random:float %game-height:float))))
+
+(define-method (spawn-random-dirt-ball (mode <super-bloom-mode>))
+ (spawn-dirt-ball mode (vec2 (if (= (random 2) 0)
+ -32.0
+ (+ %game-width:float 32.0))
+ (+ (/ %game-height 2.0)
+ (* (/ %game-height 2.0)
+ (- (random:float 2.0) 1.0))))))
+
+(define-method (wave1 (mode <super-bloom-mode>))
+ (spawn-random-water mode)
+ (sleep 1.0)
+ (spawn-random-water mode)
+ (sleep 1.0)
+ (spawn-random-dirt-ball mode))
+
+(define-method (wave2 (mode <super-bloom-mode>))
+ (spawn-random-water mode)
+ (spawn-random-water mode)
+ (sleep 1.0)
+ (spawn-random-water mode)
+ (spawn-random-water mode)
+ (sleep 1.0)
+ (spawn-random-dirt-ball mode)
+ (sleep 1.0)
+ (spawn-random-dirt-ball mode)
+ (sleep 1.0)
+ (spawn-random-dirt-ball mode))
+
+(define-method (wave3 (mode <super-bloom-mode>))
+ (spawn-random-water mode)
+ (spawn-random-water mode)
+ (spawn-random-water mode)
+ (spawn-random-water mode)
+ (spawn-random-water mode)
+ (spawn-random-water mode)
+ (sleep 1.0)
+ (spawn-random-dirt-ball mode)
+ (sleep 1.0)
+ (spawn-random-dirt-ball mode)
+ (spawn-random-dirt-ball mode)
+ (sleep 1.0)
+ (spawn-random-dirt-ball mode))
+
+(define hw (/ %game-width:float 2.0))
+(define hh (/ %game-height:float 2.0))
+
+(define-method (wave4 (mode <super-bloom-mode>))
+ (let ((offset 200.0))
+ (spawn-random-water mode)
+ (spawn-random-water mode)
+ (sleep 1.0)
+ (spawn-dirt-ball mode (vec2 hw (+ hh offset)))
+ (spawn-dirt-ball mode (vec2 hw (- hh offset)))
+ (spawn-dirt-ball mode (vec2 (+ hw offset) hh))
+ (spawn-dirt-ball mode (vec2 (- hw offset) hh))))
+
+(define waves (vector wave1 wave2 wave3 wave4))
+
+(define-method (do-random-wave (mode <super-bloom-mode>))
+ (let ((wave (vector-ref waves (random (vector-length waves)))))
+ (wave mode)))
+
+(define-method (start-game (mode <super-bloom-mode>))
+ (run-script mode
+ (spawn-water mode (vec2 120.0 100.0))
+ (sleep 1.0)
+ (spawn-water mode (vec2 160.0 140.0))
+ (sleep 1.0)
+ (spawn-water mode (vec2 200.0 100.0))
+ (sleep 3.0)
+ (wave1 mode)
+ (sleep 5.0)
+ (wave2 mode)
+ (sleep 5.0)
+ (forever
+ (do-random-wave mode)
+ (sleep 5.0))))
(define-method (player (mode <super-bloom-mode>))
(& (parent mode) player))
@@ -140,28 +241,6 @@
(define-method (player-move-up-stop (mode <super-bloom-mode>))
(set! (move-up? (player mode)) #f))
-(define-method (add-random-water (mode <super-bloom-mode>))
- (let ((p (vec2 (random:float %game-width:float) (random:float %game-height:float))))
- (attach-to (parent mode)
- (make <water>
- #:rank 3
- #:position p
- #:quadtree (quadtree mode)))))
-
-(define-method (add-random-dirt-ball (mode <super-bloom-mode>))
- (let ((p (vec2 (if (= (random 2) 0) -32.0 (+ %game-width:float 32.0))
- (+ (/ %game-height 2.0)
- (* (/ %game-height 2.0)
- (- (random:float 2.0) 1.0))))))
- (attach-to (parent mode)
- (make <dirt-ball>
- #:rank 3
- #:position p
- #:quadtree (quadtree mode)
- #:flower (& (parent mode) flower)
- #:speed 1.0
- #:explosion-particles (& (parent mode) explosion-particles)))))
-
(define-method (do-spray-water (mode <super-bloom-mode>))
(spray-water (player mode)))
@@ -169,17 +248,27 @@
(exit-catbird))
(define-method (update (mode <super-bloom-mode>) dt)
+ (with-agenda (agenda mode)
+ (update-agenda dt))
(let* ((scene (parent mode))
(flower (& scene flower)))
(if flower
(when (= (growth-progress flower) (growth-goal flower))
(stop-moving (& scene player))
+ (for-each-child (lambda (child)
+ (when (is-a? child <dirt-ball>)
+ (set! (dead? child) #t)))
+ scene)
(replace-major-mode scene (make <win-mode>)))
(begin
(pk 'no-flower)
(stop-moving (& scene player))
(replace-major-mode scene (make <game-over-mode>))))))
+(define-method (do-reset (mode <super-bloom-mode>))
+ (clear (parent mode))
+ (replace-major-mode (parent mode) (make <super-bloom-mode>)))
+
(bind-input <super-bloom-mode> (key-press 'escape) do-quit)
(bind-input <super-bloom-mode> (key-press 'left) player-move-left)
(bind-input <super-bloom-mode> (key-release 'left) player-move-left-stop)
@@ -192,6 +281,7 @@
(bind-input <super-bloom-mode> (key-press 'space) add-random-water)
(bind-input <super-bloom-mode> (key-press 'return) add-random-dirt-ball)
(bind-input <super-bloom-mode> (key-press 'z) do-spray-water)
+(bind-input <super-bloom-mode> (key-press 'r) do-reset)
(define-class <game-over-mode> (<major-mode>))
diff --git a/super-bloom/player.scm b/super-bloom/player.scm
index 4e00c1d..adc9c68 100644
--- a/super-bloom/player.scm
+++ b/super-bloom/player.scm
@@ -166,5 +166,5 @@
;; (make-particle-emitter (world-hitbox player)
;; 10 5))
(run-script player
- (blink player 10 (steps 5))
+ (blink player 5 (steps 5))
(set! (invincible? player) #f))))