From 46269dcb2fa3ddcddaef81d8769784705613500c Mon Sep 17 00:00:00 2001 From: David Thompson Date: Sun, 4 Jun 2023 12:32:03 -0400 Subject: Add splash screen. --- Makefile.am | 1 + super-bloom/common.scm | 11 ++++++ super-bloom/main.scm | 14 ++------ super-bloom/splash.scm | 95 ++++++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 110 insertions(+), 11 deletions(-) create mode 100644 super-bloom/splash.scm 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 + water)) (define %default-width 640) @@ -66,4 +69,12 @@ (define (steps n) (* n (current-timestep))) +(define-class ()) + +(define-method (width (scene )) + %game-width:float) + +(define-method (height (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 () @@ -67,21 +67,13 @@ (add-region (current-kernel) region) region)) -(define-class ()) - -(define-method (width (scene )) - %game-width:float) - -(define-method (height (scene )) - %game-height:float) - (define (init) (let ((region (create-upscaled-centered-region %game-width %game-height #:name 'main)) - (scene (make #:name 'super-bloom)) + (scene (make #:name 'splash-screen)) (camera (make #:width %game-width #:height %game-height))) (replace-scene region scene) (set-camera region camera) - (replace-major-mode scene (make )))) + (replace-major-mode scene (make )))) (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 ()) + +(define-asset (chickadee-texture (file (scope-datadir "assets/images/chickadee.png"))) + (load-image file)) + +(define-class ()) + +(define-method (go-to-game (mode )) + (let ((region (find-region-by-name 'main)) + (scene (make #:name 'super-bloom))) + (replace-scene region scene) + (replace-major-mode scene (make )))) + +(define-method (on-enter (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 + #:name 'background + #:rank 0 + #:painter (full-rect white))) + (fader (make + #:name 'fader + #:rank 999 + #:width %game-width:float + #:height %game-height:float)) + (sprite (make + #:name 'sprite + #:rank 1 + #:texture chickadee-texture + #:origin (vec2 8.0 8.0) + #:scale 0.5)) + (label1 (make