summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile.am1
-rw-r--r--super-bloom/common.scm11
-rw-r--r--super-bloom/main.scm14
-rw-r--r--super-bloom/splash.scm95
4 files changed, 110 insertions, 11 deletions
diff --git a/Makefile.am b/Makefile.am
index 7b90451..9624e82 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -27,6 +27,7 @@ SOURCES = \
super-bloom/dirt-ball.scm \
super-bloom/player.scm \
super-bloom/game.scm \
+ super-bloom/splash.scm \
super-bloom/main.scm
EXTRA_DIST = \
diff --git a/super-bloom/common.scm b/super-bloom/common.scm
index 08d4eae..0e55b90 100644
--- a/super-bloom/common.scm
+++ b/super-bloom/common.scm
@@ -14,6 +14,8 @@
(define-module (super-bloom common)
#:use-module (catbird asset)
+ #:use-module (catbird mixins)
+ #:use-module (catbird scene)
#:use-module (chickadee)
#:use-module (chickadee audio)
#:use-module (chickadee graphics text)
@@ -32,6 +34,7 @@
spray-sound
random:float
steps
+ <game-scene>
water))
(define %default-width 640)
@@ -66,4 +69,12 @@
(define (steps n)
(* n (current-timestep)))
+(define-class <game-scene> (<scene>))
+
+(define-method (width (scene <game-scene>))
+ %game-width:float)
+
+(define-method (height (scene <game-scene>))
+ %game-height:float)
+
(define-accessor water)
diff --git a/super-bloom/main.scm b/super-bloom/main.scm
index 390003b..72f4254 100644
--- a/super-bloom/main.scm
+++ b/super-bloom/main.scm
@@ -24,7 +24,7 @@
#:use-module (chickadee math rect)
#:use-module (oop goops)
#:use-module (super-bloom common)
- #:use-module (super-bloom game)
+ #:use-module (super-bloom splash)
#:export (launch-game))
(define-class <upscaled-centered-region> (<region>)
@@ -67,21 +67,13 @@
(add-region (current-kernel) region)
region))
-(define-class <game-scene> (<scene>))
-
-(define-method (width (scene <game-scene>))
- %game-width:float)
-
-(define-method (height (scene <game-scene>))
- %game-height:float)
-
(define (init)
(let ((region (create-upscaled-centered-region %game-width %game-height #:name 'main))
- (scene (make <game-scene> #:name 'super-bloom))
+ (scene (make <game-scene> #:name 'splash-screen))
(camera (make <camera-2d> #:width %game-width #:height %game-height)))
(replace-scene region scene)
(set-camera region camera)
- (replace-major-mode scene (make <super-bloom-mode>))))
+ (replace-major-mode scene (make <splash-screen-mode>))))
(define (launch-game)
(run-catbird init
diff --git a/super-bloom/splash.scm b/super-bloom/splash.scm
new file mode 100644
index 0000000..6f7432b
--- /dev/null
+++ b/super-bloom/splash.scm
@@ -0,0 +1,95 @@
+;;; Copyright 2023 David Thompson
+;;;
+;;; Licensed under the Apache License, Version 2.0 (the "License");
+;;; you may not use this file except in compliance with the License.
+;;; You may obtain a copy of the License at
+;;;
+;;; http://www.apache.org/licenses/LICENSE-2.0
+;;;
+;;; Unless required by applicable law or agreed to in writing, software
+;;; distributed under the License is distributed on an "AS IS" BASIS,
+;;; WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+;;; See the License for the specific language governing permissions and
+;;; limitations under the License.
+
+(define-module (super-bloom splash)
+ #:use-module (catbird)
+ #:use-module (catbird asset)
+ #:use-module (catbird camera)
+ #:use-module (catbird kernel)
+ #:use-module (catbird mixins)
+ #:use-module (catbird mode)
+ #:use-module (catbird node)
+ #:use-module (catbird node-2d)
+ #:use-module (catbird region)
+ #:use-module (catbird scene)
+ #:use-module (chickadee data quadtree)
+ #:use-module (chickadee graphics color)
+ #:use-module (chickadee graphics path)
+ #: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 common)
+ #:use-module (super-bloom game)
+ #:export (<splash-screen-mode>))
+
+(define-asset (chickadee-texture (file (scope-datadir "assets/images/chickadee.png")))
+ (load-image file))
+
+(define-class <splash-screen-mode> (<major-mode>))
+
+(define-method (go-to-game (mode <splash-screen-mode>))
+ (let ((region (find-region-by-name 'main))
+ (scene (make <game-scene> #:name 'super-bloom)))
+ (replace-scene region scene)
+ (replace-major-mode scene (make <super-bloom-mode>))))
+
+(define-method (on-enter (mode <splash-screen-mode>))
+ (define (full-rect color)
+ (with-style ((fill-color color))
+ (fill (rectangle (vec2 0.0 0.0)
+ %game-width:float
+ %game-height:float))))
+ (let ((scene (parent mode))
+ (bg (make <canvas>
+ #:name 'background
+ #:rank 0
+ #:painter (full-rect white)))
+ (fader (make <canvas>
+ #:name 'fader
+ #:rank 999
+ #:width %game-width:float
+ #:height %game-height:float))
+ (sprite (make <sprite>
+ #:name 'sprite
+ #:rank 1
+ #:texture chickadee-texture
+ #:origin (vec2 8.0 8.0)
+ #:scale 0.5))
+ (label1 (make <label>
+ #:name 'built-with-label
+ #:rank 1
+ #:font monogram-font
+ #:color black
+ #:text "Built with Chickadee"))
+ (label2 (make <label>
+ #:name 'url-label
+ #:rank 1
+ #:font monogram-font
+ #:color black
+ #:text "https://dthompson.us/projects/chickadee.html")))
+ (run-script scene
+ (attach-to scene bg fader sprite label1 label2)
+ (center-in-parent sprite)
+ (center-horizontal-in-parent label1)
+ (center-horizontal-in-parent label2)
+ (place-below sprite label1 #:padding 16.0)
+ (place-below label1 label2 #:padding 16.0)
+ (sleep 2.0)
+ (tween 1.0 (make-color 0.0 0.0 0.0 0.0001) (make-color 0.0 0.0 0.0 1.0)
+ (lambda (color)
+ (set! (painter fader) (full-rect color)))
+ #:interpolate color-lerp)
+ (go-to-game mode))))