summaryrefslogtreecommitdiff
path: root/apple-town-fair/splash.scm
diff options
context:
space:
mode:
authorDavid Thompson <dthompson@vistahigherlearning.com>2022-10-28 08:00:48 -0400
committerDavid Thompson <dthompson@vistahigherlearning.com>2022-10-28 08:00:48 -0400
commitd2ca3fe8b59c93baf9f5c29b14710e5d1eed2e7a (patch)
tree73a09c1f91a1969c31df6ee1196fcfe03d8a1d8a /apple-town-fair/splash.scm
First commit!
Diffstat (limited to 'apple-town-fair/splash.scm')
-rw-r--r--apple-town-fair/splash.scm95
1 files changed, 95 insertions, 0 deletions
diff --git a/apple-town-fair/splash.scm b/apple-town-fair/splash.scm
new file mode 100644
index 0000000..8a1b0e3
--- /dev/null
+++ b/apple-town-fair/splash.scm
@@ -0,0 +1,95 @@
+;;; Copyright © 2022 David Thompson <davet@gnu.org>
+;;;
+;;; This program is free software: you can redistribute it and/or
+;;; modify it under the terms of the GNU General Public License as
+;;; published by the Free Software Foundation, either version 3 of the
+;;; License, or (at your option) any later version.
+;;;
+;;; This program is distributed in the hope that it will be useful,
+;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+;;; General Public License for more details.
+;;;
+;;; You should have received a copy of the GNU General Public License
+;;; along with this program. If not, see
+;;; <http://www.gnu.org/licenses/>.
+(define-module (apple-town-fair splash)
+ #:use-module (apple-town-fair assets)
+ #:use-module (apple-town-fair config)
+ #:use-module (apple-town-fair common)
+ #:use-module (chickadee graphics color)
+ #:use-module (chickadee graphics path)
+ #:use-module (chickadee math vector)
+ #:use-module (chickadee scripting)
+ #:use-module (oop goops)
+ #:use-module (catbird)
+ #:use-module (catbird camera)
+ #:use-module (catbird kernel)
+ #:use-module (catbird mode)
+ #:use-module (catbird node)
+ #:use-module (catbird node-2d)
+ #:use-module (catbird region)
+ #:use-module (catbird scene)
+ #:export (launch-game))
+
+(define-class <splash-mode> (<major-mode>))
+
+(define %text-color (rgb #x181425))
+(define %background-color white)
+
+(define-method (on-enter (mode <splash-mode>))
+ (let ((scene (parent mode)))
+ (attach-to scene
+ (make <canvas>
+ #:painter
+ (with-style ((fill-color %background-color))
+ (fill
+ (rectangle (vec2 0.0 0.0) %game-width %game-height))))
+ (make <sprite>
+ #:texture chickadee-image
+ #:position (vec2 (/ %game-width 2.0)
+ (/ %game-height 2.0))
+ #:origin (vec2 8.0 8.0)
+ #:scale (vec2 4.0 4.0))
+ (make <label>
+ #:rank 1
+ #:position (vec2 (/ %game-width 2.0) 70.5)
+ #:font monogram-font
+ #:color %text-color
+ #:align 'center
+ #:vertical-align 'center
+ #:text "Made with Chickadee")
+ (make <label>
+ #:rank 1
+ #:position (vec2 (/ %game-width 2.0) 50.5)
+ #:font monogram-font
+ #:color %text-color
+ #:align 'center
+ #:vertical-align 'center
+ #:text "https://dthompson.us/projects/chickadee.html"))
+ (run-script scene
+ (unless (getenv "SKIP_SPLASH")
+ (fade-in scene 1.0)
+ (sleep 1.0)
+ (fade-out scene 1.0))
+ (let ((new-scene (make <scene>))
+ (region (car (all-regions))))
+ ;;(replace-scene region (make-game-scene))
+ #t))))
+
+(define (launch-game)
+ (set! *random-state* (random-state-from-platform))
+ (run-catbird
+ (lambda ()
+ (let ((region (create-full-region))
+ (scene (make <scene>)))
+ (take-controller-focus 0 region)
+ (replace-scene region scene)
+ (replace-major-mode scene (make <splash-mode>))
+ (set! (camera region)
+ (make <camera-2d>
+ #:width %game-width
+ #:height %game-height))))
+ #:width %window-width
+ #:height %window-height
+ #:title "Apple Town Fair"))