From d2ca3fe8b59c93baf9f5c29b14710e5d1eed2e7a Mon Sep 17 00:00:00 2001 From: David Thompson Date: Fri, 28 Oct 2022 08:00:48 -0400 Subject: First commit! --- apple-town-fair/assets.scm | 35 +++++++++++++++++ apple-town-fair/common.scm | 60 +++++++++++++++++++++++++++++ apple-town-fair/config.scm | 25 ++++++++++++ apple-town-fair/splash.scm | 95 ++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 215 insertions(+) create mode 100644 apple-town-fair/assets.scm create mode 100644 apple-town-fair/common.scm create mode 100644 apple-town-fair/config.scm create mode 100644 apple-town-fair/splash.scm (limited to 'apple-town-fair') diff --git a/apple-town-fair/assets.scm b/apple-town-fair/assets.scm new file mode 100644 index 0000000..1f9b15e --- /dev/null +++ b/apple-town-fair/assets.scm @@ -0,0 +1,35 @@ +;;; Copyright © 2022 David Thompson +;;; +;;; 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 +;;; . +(define-module (apple-town-fair assets) + #:use-module (catbird asset) + #:export (monogram-font + chickadee-image)) + +(define (scope-datadir file-name) + (let ((prefix (or (getenv "APPLE_TOWN_FAIR_DATADIR") (getcwd)))) + (string-append prefix "/" file-name))) + +(define (font-file file-name) + (scope-datadir (string-append "assets/fonts/" file-name))) + +(define (image-file file-name) + (scope-datadir (string-append "assets/images/" file-name))) + +(define (audio-file file-name) + (scope-datadir (string-append "assets/audio/" file-name))) + +(define-font monogram-font (font-file "monogram_extended.ttf") 12) +(define-image chickadee-image (image-file "chickadee.png")) diff --git a/apple-town-fair/common.scm b/apple-town-fair/common.scm new file mode 100644 index 0000000..5fe5bb3 --- /dev/null +++ b/apple-town-fair/common.scm @@ -0,0 +1,60 @@ +;;; Copyright © 2022 David Thompson +;;; +;;; 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 +;;; . +(define-module (apple-town-fair common) + #:use-module (apple-town-fair config) + #:use-module (chickadee) + #: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 scene) + #:use-module (catbird node) + #:use-module (catbird node-2d) + #:export (steps + full-screen-rectangle + fade-in + fade-out)) + +(define (steps n) + (* n (current-timestep))) + +(define (full-screen-rectangle color) + (with-style ((fill-color color)) + (fill + (rectangle (vec2 0.0 0.0) %game-width %game-height)))) + +(define (black-alpha alpha) + (make-color 0.0 0.0 0.0 alpha)) + +(define (fade scene start-alpha end-alpha duration) + (let ((bg (make + #:rank 999 + #:painter (full-screen-rectangle + (black-alpha start-alpha))))) + (attach-to scene bg) + (tween duration start-alpha end-alpha + (lambda (a) + (set! (painter bg) + (full-screen-rectangle + (black-alpha a))))) + (detach bg))) + +(define-method (fade-in (scene ) duration) + (fade scene 1.0 0.0 duration)) + +(define-method (fade-out (scene ) duration) + (fade scene 0.0 1.0 duration)) diff --git a/apple-town-fair/config.scm b/apple-town-fair/config.scm new file mode 100644 index 0000000..7bf7a5b --- /dev/null +++ b/apple-town-fair/config.scm @@ -0,0 +1,25 @@ +;;; Copyright © 2022 David Thompson +;;; +;;; 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 +;;; . +(define-module (apple-town-fair config) + #:export (%window-width + %window-height + %game-width + %game-height)) + +(define %window-width 960) +(define %window-height 720) +(define %game-width 320) +(define %game-height 240) 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 +;;; +;;; 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 +;;; . +(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 ()) + +(define %text-color (rgb #x181425)) +(define %background-color white) + +(define-method (on-enter (mode )) + (let ((scene (parent mode))) + (attach-to scene + (make + #:painter + (with-style ((fill-color %background-color)) + (fill + (rectangle (vec2 0.0 0.0) %game-width %game-height)))) + (make + #: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