From 8fc01b81e0f95c8ea187d179b6f6a6b9afc4e79e Mon Sep 17 00:00:00 2001 From: David Thompson Date: Sun, 25 Apr 2021 14:51:00 -0400 Subject: Break code up into modules. --- Makefile.am | 6 +- configure.ac | 4 +- game.scm | 1213 --------------------------------------------- run-game | 2 +- test-subject/assets.scm | 52 ++ test-subject/device.scm | 42 ++ test-subject/game.scm | 1126 +++++++++++++++++++++++++++++++++++++++++ test-subject/text-box.scm | 37 ++ 8 files changed, 1265 insertions(+), 1217 deletions(-) delete mode 100644 game.scm create mode 100644 test-subject/assets.scm create mode 100644 test-subject/device.scm create mode 100644 test-subject/game.scm create mode 100644 test-subject/text-box.scm diff --git a/Makefile.am b/Makefile.am index 4f5cd6a..70738c9 100644 --- a/Makefile.am +++ b/Makefile.am @@ -21,7 +21,11 @@ SUFFIXES = .scm .go moddir=$(prefix)/share/guile/site/$(GUILE_EFFECTIVE_VERSION) godir=$(libdir)/guile/$(GUILE_EFFECTIVE_VERSION)/site-ccache -SOURCES = game.scm +SOURCES = \ + test-subject/assets.scm \ + test-subject/text-box.scm \ + test-subject/device.scm \ + test-subject/game.scm EXTRA_DIST += \ COPYING diff --git a/configure.ac b/configure.ac index 582cdb7..21e90ac 100644 --- a/configure.ac +++ b/configure.ac @@ -1,7 +1,7 @@ dnl -*- Autoconf -*- -AC_INIT(spring-lisp-game-jam-2021, 0.1.0) -AC_CONFIG_SRCDIR(lisp-game-jam) +AC_INIT(test-subject, 0.1.0) +AC_CONFIG_SRCDIR(test-subject) AC_CONFIG_AUX_DIR([build-aux]) AM_INIT_AUTOMAKE([color-tests -Wall -Wno-portability foreign]) AM_SILENT_RULES([yes]) diff --git a/game.scm b/game.scm deleted file mode 100644 index ef0234c..0000000 --- a/game.scm +++ /dev/null @@ -1,1213 +0,0 @@ -(define-module (game) - #:use-module (chickadee audio) - #:use-module (chickadee graphics color) - #:use-module (chickadee graphics font) - #:use-module (chickadee graphics texture) - #:use-module (chickadee graphics viewport) - #:use-module (chickadee math vector) - #:use-module (chickadee scripting) - #:use-module (ice-9 match) - #:use-module (oop goops) - #:use-module (srfi srfi-1) - #:use-module (starling asset) - #:use-module (starling gui) - #:use-module (starling kernel) - #:use-module (starling node) - #:use-module (starling node-2d) - #:use-module (starling ring-buffer) - #:use-module (starling scene) - #:duplicates (merge-generics replace warn-override-core warn last) - #:export (launch-game)) - - -;;; -;;; Constants -;;; - -(define window-width 1280) -(define window-height 720) -(define game-width 640) -(define game-height 360) -(define player-display-name "") - - -;;; -;;; Assets -;;; - -(define-asset dialog-box-texture (load-image "assets/images/dialog-box.png")) -(define-asset button-press-texture (load-image "assets/images/button-press.png")) -(define-asset darkness (load-image "assets/images/darkness.png")) -(define-asset lightness (load-image "assets/images/lightness.png")) -(define-asset room-background (load-image "assets/images/room.png")) -(define-asset door-lock-texture (load-image "assets/images/door-lock.png")) -(define-asset pin-entry-background (load-image "assets/images/pin-entry-background.png")) -(define-asset door-texture (load-image "assets/images/door.png")) -(define-asset terminal-texture (load-image "assets/images/terminal.png")) -(define-asset terminal-background (load-image "assets/images/terminal-background.png")) -(define-asset control-panel-texture (load-image "assets/images/control-panel.png")) -(define-asset fridge-texture (load-image "assets/images/fridge.png")) -(define-asset window-texture (load-image "assets/images/window.png")) -(define-asset notebook-texture (load-image "assets/images/notebook.png")) -(define-asset notebook-background (load-image "assets/images/notebook-background.png")) -(define-asset monogram-font (load-font "assets/fonts/monogram_extended.ttf" 12)) -(define-asset monogram-font-big (load-font "assets/fonts/monogram_extended.ttf" 24)) -(define-asset old-fax-font (load-font "assets/fonts/old-fax.ttf" 12)) -(define-asset click-sound (load-audio "assets/sounds/click1.wav")) -(define-asset key-press-sound (load-audio "assets/sounds/switch6.wav")) -(define-asset device-sound (load-audio "assets/sounds/switch38.wav")) -(define-asset background-music (load-audio "assets/sounds/ambientmain_0.ogg" #:mode 'stream)) -(define-asset credits-music (load-audio "assets/sounds/end-theme.mp3" #:mode 'stream)) - - -;;; -;;; Text Box -;;; - -(define-class () - (text #:accessor text #:init-keyword #:text #:init-value "" #:watch? #t)) - -(define-method (on-change (text-box ) slot-name old new) - (case slot-name - ((text) - (let ((l (& text-box text))) - (when l - (set! (text l) new)))) - (else - (next-method)))) - -(define-method (apply-theme (text-box )) - (next-method) - (replace text-box - (make