From ea0d3009fa7020d75c1657cb532570305de699a6 Mon Sep 17 00:00:00 2001 From: David Thompson Date: Fri, 22 Sep 2023 08:24:42 -0400 Subject: Allow game to be properly installable. --- super-bloom/common.scm | 13 +++++++------ super-bloom/config.scm.in | 18 ++++++++++++++++++ super-bloom/dirt-ball.scm | 2 +- super-bloom/flower.scm | 2 +- super-bloom/game.scm | 10 +++++----- super-bloom/player.scm | 2 +- super-bloom/splash.scm | 2 +- super-bloom/water.scm | 2 +- 8 files changed, 35 insertions(+), 16 deletions(-) create mode 100644 super-bloom/config.scm.in (limited to 'super-bloom') diff --git a/super-bloom/common.scm b/super-bloom/common.scm index 0e55b90..7dd50a1 100644 --- a/super-bloom/common.scm +++ b/super-bloom/common.scm @@ -20,6 +20,7 @@ #:use-module (chickadee audio) #:use-module (chickadee graphics text) #:use-module (oop goops) + #:use-module (super-bloom config) #:export (%default-width %default-height %game-width @@ -45,22 +46,22 @@ (define %game-height:float (exact->inexact %game-height)) (define (scope-datadir file-name) - (let ((prefix (or (getenv "SUPERBLOOM_DATADIR") (getcwd)))) + (let ((prefix (or (getenv "SUPERBLOOM_DATADIR") %datadir))) (string-append prefix "/" file-name))) -(define-asset (monogram-font (file (scope-datadir "assets/fonts/monogram_extended.ttf"))) +(define-asset (monogram-font (file (scope-datadir "fonts/monogram_extended.ttf"))) (load-font file 12 #:smooth? #f)) -(define-asset (explosion-sound (file (scope-datadir "assets/audio/explosion.wav"))) +(define-asset (explosion-sound (file (scope-datadir "audio/explosion.wav"))) (load-audio file)) -(define-asset (absorb-sound (file (scope-datadir "assets/audio/absorb.wav"))) +(define-asset (absorb-sound (file (scope-datadir "audio/absorb.wav"))) (load-audio file)) -(define-asset (watered-sound (file (scope-datadir "assets/audio/watered.wav"))) +(define-asset (watered-sound (file (scope-datadir "audio/watered.wav"))) (load-audio file)) -(define-asset (spray-sound (file (scope-datadir "assets/audio/spray.wav"))) +(define-asset (spray-sound (file (scope-datadir "audio/spray.wav"))) (load-audio file)) (define (random:float n) diff --git a/super-bloom/config.scm.in b/super-bloom/config.scm.in new file mode 100644 index 0000000..861087a --- /dev/null +++ b/super-bloom/config.scm.in @@ -0,0 +1,18 @@ +;;; 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 config) + #:export (%datadir)) + +(define %datadir "@datadir@/super-bloom") diff --git a/super-bloom/dirt-ball.scm b/super-bloom/dirt-ball.scm index 43c8d4c..2d8b361 100644 --- a/super-bloom/dirt-ball.scm +++ b/super-bloom/dirt-ball.scm @@ -31,7 +31,7 @@ #:export ( dead?)) -(define-asset (dirt-ball-tileset (file (scope-datadir "assets/images/dirt-ball.png"))) +(define-asset (dirt-ball-tileset (file (scope-datadir "images/dirt-ball.png"))) (load-tileset file 32 32)) (define-class () diff --git a/super-bloom/flower.scm b/super-bloom/flower.scm index 78e8f03..ff3e25a 100644 --- a/super-bloom/flower.scm +++ b/super-bloom/flower.scm @@ -38,7 +38,7 @@ (define %max-water 1) -(define-asset (flower-tileset (file (scope-datadir "assets/images/flower.png"))) +(define-asset (flower-tileset (file (scope-datadir "images/flower.png"))) (load-tileset file 48 48)) ;; Every growth-interval, the flower gains 1 growth point (accumulated diff --git a/super-bloom/game.scm b/super-bloom/game.scm index 5cdb6a9..12da7e1 100644 --- a/super-bloom/game.scm +++ b/super-bloom/game.scm @@ -39,19 +39,19 @@ #:export ( reset-game!)) -(define-asset (background-texture (file (scope-datadir "assets/images/background.png"))) +(define-asset (background-texture (file (scope-datadir "images/background.png"))) (load-image file)) -(define-asset (chickadee-texture (file (scope-datadir "assets/images/chickadee.png"))) +(define-asset (chickadee-texture (file (scope-datadir "images/chickadee.png"))) (load-image file)) -(define-asset (water-particle-texture (file (scope-datadir "assets/images/water-particle.png"))) +(define-asset (water-particle-texture (file (scope-datadir "images/water-particle.png"))) (load-image file)) -(define-asset (trail-particle-texture (file (scope-datadir "assets/images/trail-particle.png"))) +(define-asset (trail-particle-texture (file (scope-datadir "images/trail-particle.png"))) (load-image file)) -(define-asset (explosion-particle-texture (file (scope-datadir "assets/images/explosion-particle.png"))) +(define-asset (explosion-particle-texture (file (scope-datadir "images/explosion-particle.png"))) (load-image file)) (define (make-game-quadtree) diff --git a/super-bloom/player.scm b/super-bloom/player.scm index adc9c68..c3271fd 100644 --- a/super-bloom/player.scm +++ b/super-bloom/player.scm @@ -43,7 +43,7 @@ (define %max-water 1) -(define-asset (player-tileset (file (scope-datadir "assets/images/player.png"))) +(define-asset (player-tileset (file (scope-datadir "images/player.png"))) (load-tileset file 32 32)) (define-class () diff --git a/super-bloom/splash.scm b/super-bloom/splash.scm index 6f7432b..2d93bcf 100644 --- a/super-bloom/splash.scm +++ b/super-bloom/splash.scm @@ -35,7 +35,7 @@ #:use-module (super-bloom game) #:export ()) -(define-asset (chickadee-texture (file (scope-datadir "assets/images/chickadee.png"))) +(define-asset (chickadee-texture (file (scope-datadir "images/chickadee.png"))) (load-image file)) (define-class ()) diff --git a/super-bloom/water.scm b/super-bloom/water.scm index d2533fd..94b90a3 100644 --- a/super-bloom/water.scm +++ b/super-bloom/water.scm @@ -31,7 +31,7 @@ absorb! on-splash)) -(define-asset (water-tileset (file (scope-datadir "assets/images/water.png"))) +(define-asset (water-tileset (file (scope-datadir "images/water.png"))) (load-tileset file 32 32)) (define-class () -- cgit v1.2.3