summaryrefslogtreecommitdiff
path: root/super-bloom
diff options
context:
space:
mode:
Diffstat (limited to 'super-bloom')
-rw-r--r--super-bloom/game.scm75
1 files changed, 49 insertions, 26 deletions
diff --git a/super-bloom/game.scm b/super-bloom/game.scm
index db5b25c..311319c 100644
--- a/super-bloom/game.scm
+++ b/super-bloom/game.scm
@@ -58,6 +58,8 @@
(make-quadtree (make-rect 0.0 0.0 %game-width %game-height)))
(define-class <super-bloom-mode> (<major-mode>)
+ (show-instructions? #:accessor show-instructions? #:init-value #t
+ #:init-keyword #:show-instructions?)
(quadtree #:getter quadtree #:init-thunk make-game-quadtree))
(define-method (on-enter (mode <super-bloom-mode>))
@@ -120,7 +122,9 @@
#:quadtree (quadtree mode)
#:growth-goal 20
#:growth-interval 3.0))
- (start-game mode)))
+ (run-script mode
+ (show-instructions mode)
+ (start-game mode))))
(define-method (spawn-water (mode <super-bloom-mode>) position)
(attach-to (parent mode)
@@ -205,21 +209,45 @@
(let ((wave (vector-ref waves (random (vector-length waves)))))
(wave mode)))
+(define-method (show-instructions (mode <super-bloom-mode>))
+ (when (show-instructions? mode)
+ (set! (show-instructions? mode) #f)
+ (let ((scene (parent mode))
+ (label (make <label>
+ #:name 'instructions
+ #:rank 99
+ #:font monogram-font)))
+ (define (show-instruction str)
+ (set! (text label) str)
+ (center-in-parent label))
+ (sleep 1.0)
+ (attach-to scene label)
+ (show-instruction "move with <arrows>")
+ (sleep 2.0)
+ (show-instruction "collect water by moving over droplets")
+ (sleep 2.0)
+ (show-instruction "spray stored water with <z> to water the plant")
+ (sleep 2.0)
+ (show-instruction "spray the dirt balls trying to kill the flower")
+ (sleep 2.0)
+ (show-instruction "good luck!")
+ (sleep 2.0)
+ (detach label))))
+
(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))))
+ (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))
@@ -264,9 +292,12 @@
(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>)))
+(define-method (do-reset (mode <major-mode>))
+ (let ((scene (parent mode)))
+ (clear scene)
+ (replace-major-mode scene
+ (make <super-bloom-mode>
+ #:show-instructions? #f))))
(bind-input <super-bloom-mode> (key-press 'escape) do-quit)
(bind-input <super-bloom-mode> (key-press 'left) player-move-left)
@@ -302,10 +333,6 @@
(& scene instructions-label)
#:padding 16.0)))
-(define-method (do-reset (mode <game-over-mode>))
- (clear (parent mode))
- (replace-major-mode (parent mode) (make <super-bloom-mode>)))
-
(bind-input <game-over-mode> (key-press 'escape) do-quit)
(bind-input <game-over-mode> (key-press 'z) do-reset)
@@ -331,10 +358,6 @@
(& scene instructions-label)
#:padding 16.0)))
-(define-method (do-reset (mode <win-mode>))
- (clear (parent mode))
- (replace-major-mode (parent mode) (make <super-bloom-mode>)))
-
(bind-input <win-mode> (key-press 'escape) do-quit)
(bind-input <win-mode> (key-press 'z) do-reset)