summaryrefslogtreecommitdiff
path: root/bonnie-bee
diff options
context:
space:
mode:
Diffstat (limited to 'bonnie-bee')
-rw-r--r--bonnie-bee/game.scm81
1 files changed, 63 insertions, 18 deletions
diff --git a/bonnie-bee/game.scm b/bonnie-bee/game.scm
index b868cd2..4d02490 100644
--- a/bonnie-bee/game.scm
+++ b/bonnie-bee/game.scm
@@ -202,7 +202,6 @@
(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)
medium-enemy-bullet
(position popcorn)
@@ -432,7 +431,9 @@
(tween 0.5 -2.0 0.0
(lambda (dy)
(change-velocity popcorn 0.0 dy)))
- (let ((d (direction-to popcorn (player game))))
+ (let ((d (vec2-normalize
+ (vec2- (vec2+ (position (player game)) (vec2 0.0 16.0))
+ (position popcorn)))))
(tween 0.5 0.0 4.0
(lambda (speed)
(change-velocity popcorn (* (vec2-x d) speed) (* (vec2-y d) speed)))))))
@@ -504,9 +505,22 @@
(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 14.0))
+ (sleep 7.0))
;; Boss
(unless (getenv "SKIP_BOSS")
+ (run-script game
+ (let ((warning (make <shadow-label>
+ #:name 'warning
+ #:rank 9
+ #:position (vec2 (/ %game-width 2.0) (/ %game-height 2.0))
+ #:font monogram-font
+ #:text "WARNING!! BIG OL' BAD THING AHEAD!"
+ #:align 'center
+ #:color %text-color)))
+ (attach-to game warning)
+ (blink warning 15 0.25)
+ (detach warning)))
+ (sleep 7.0)
(spawn game (make <boss>
#:name 'boss
#:rank 2
@@ -535,7 +549,8 @@
(show (& game hud-pollen))
(for-each-child (lambda (child)
(when (or (is-a? child <actor>)
- (memq (name child) '(game-over game-complete tutorial)))
+ (memq (name child)
+ '(game-over game-complete tutorial warning)))
(detach child)))
game)
(spawn game
@@ -635,12 +650,43 @@
#:align 'center
#:color %text-color))))
+(define-method (toggle-pause (game <game>))
+ (if (paused? game)
+ (begin
+ (detach (& game pause-overlay))
+ (resume game))
+ (let ((overlay (make <node-2d>
+ #:name 'pause-overlay
+ #:rank 99)))
+ (pause game)
+ (attach-to overlay
+ (make <sprite>
+ #:texture darkness-image
+ #:tint (transparency 0.4))
+ (make <shadow-label>
+ #:position (vec2 (/ %game-width 2.0) (/ %game-height 2.0))
+ #:font monogram-font
+ #:text "PAUSED"
+ #:align 'center
+ #:vertical-align 'center
+ #:color %text-color))
+ (attach-to game overlay))))
+
+(define-method (play-again (game <game>))
+ (run-script game
+ (tween 0.5 1.0 0.0
+ (lambda (volume)
+ (set-source-volume! (music-source game) volume)))
+ (source-stop (music-source game))
+ (set-source-volume! (music-source game) 1.0))
+ (run-script game
+ (fade-out game 1.0)
+ (reset-game game)))
+
(define-method (on-key-press (game <game>) key modifiers repeat?)
(case (state game)
((play)
(case key
- ((q)
- (pop-scene (current-kernel)))
((left)
(set! (move-left? (player game)) #t))
((right)
@@ -652,24 +698,23 @@
((z)
(set! (shoot? (player game)) #t))
((x)
- (bomb (player game)))))
- ((game-over game-complete)
- (case key
+ (bomb (player game)))
((q)
(pop-scene (current-kernel)))
((return)
- (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)))))
+ (toggle-pause game))))
((intro)
(case key
((q)
- (pop-scene (current-kernel)))))))
+ (pop-scene (current-kernel)))
+ ((return)
+ (toggle-pause game))))
+ ((game-over game-complete)
+ (case key
+ ((q)
+ (pop-scene (current-kernel)))
+ ((return)
+ (play-again game))))))
(define-method (on-key-release (game <game>) key modifiers)
(case (state game)