summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Thompson <dthompson2@worcester.edu>2016-05-15 21:32:58 -0400
committerDavid Thompson <dthompson2@worcester.edu>2016-05-15 21:32:58 -0400
commit2e56bb6a0c7210c8103eb43895b180c1125291ac (patch)
treeb860c6a7d6110fd30512172d981e840eda8390e2
parentf00b115ee10e27d23de32a106bc2e0dc15ad6907 (diff)
Use proper asset path and launcher binary.
-rw-r--r--.gitignore2
-rw-r--r--Makefile.am6
-rw-r--r--configure.ac8
-rw-r--r--guix.scm4
-rw-r--r--lisparuga/config.scm.in22
-rw-r--r--lisparuga/game.scm (renamed from game.scm)83
-rw-r--r--lisparuga/view.scm18
-rw-r--r--pre-inst-env.in5
-rw-r--r--scripts/lisparuga.in43
9 files changed, 133 insertions, 58 deletions
diff --git a/.gitignore b/.gitignore
index be2aba4..16e986d 100644
--- a/.gitignore
+++ b/.gitignore
@@ -10,3 +10,5 @@
/dist/
*.go
*.tar.gz
+/lisparuga/config.scm
+/scripts/lisparuga
diff --git a/Makefile.am b/Makefile.am
index efc0a1e..7842a3f 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -36,7 +36,11 @@ SUFFIXES = .scm .go
moddir=$(prefix)/share/guile/site/$(GUILE_EFFECTIVE_VERSION)
godir=$(libdir)/guile/$(GUILE_EFFECTIVE_VERSION)/ccache
+bin_SCRIPTS = \
+ scripts/lisparuga
+
SOURCES = \
+ lisparuga/config.scm \
lisparuga/utils.scm \
lisparuga/audio.scm \
lisparuga/bullets.scm \
@@ -46,7 +50,7 @@ SOURCES = \
lisparuga/stats.scm \
lisparuga/world.scm \
lisparuga/view.scm \
- game.scm
+ lisparuga/game.scm
imagesdir = $(pkgdatadir)/images
dist_images_DATA = \
diff --git a/configure.ac b/configure.ac
index d898a1c..18e80a1 100644
--- a/configure.ac
+++ b/configure.ac
@@ -9,6 +9,14 @@ AM_SILENT_RULES([yes])
AC_PATH_PROG([GUILE], [guile])
AC_CONFIG_FILES([Makefile])
AC_CONFIG_FILES([pre-inst-env], [chmod +x pre-inst-env])
+AC_CONFIG_FILES([scripts/lisparuga], [chmod +x scripts/lisparuga])
+AC_CONFIG_FILES([lisparuga/config.scm])
+
+# Prepare a version of $datadir that does not contain references to
+# shell variables.
+lisparuga_prefix="`eval echo $prefix | sed -e"s|NONE|/usr/local|g"`"
+lisparuga_datadir="`eval eval echo $datadir | sed -e "s|NONE|$lisparuga_prefix|g"`"
+AC_SUBST([lisparuga_datadir])
GUILE_PKG([2.2 2.0])
GUILE_PROGS
diff --git a/guix.scm b/guix.scm
index a9136f6..6b1aae4 100644
--- a/guix.scm
+++ b/guix.scm
@@ -22,9 +22,7 @@
;; To setup the development environment, run the following:
;;
;; guix environment -l guix.scm
-;; ./bootstrap && ./configure \
-;; --with-libfreeimage-prefix=$(guix build freeimage) \
-;; --with-libgslcblas-prefix=$(guix build gsl)
+;; ./bootstrap && ./configure;
;;
;; To build the development snapshot, run:
;;
diff --git a/lisparuga/config.scm.in b/lisparuga/config.scm.in
new file mode 100644
index 0000000..d17db2b
--- /dev/null
+++ b/lisparuga/config.scm.in
@@ -0,0 +1,22 @@
+;;; Lisparuga
+;;; Copyright © 2016 David Thompson <davet@gnu.org>
+;;;
+;;; Lisparuga 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.
+;;;
+;;; Lisparuga 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 Lisparuga. If not, see <http://www.gnu.org/licenses/>.
+
+(define-module (lisparuga config)
+ #:export (%datadir))
+
+(define %datadir
+ (or (getenv "LISPARUGA_DATADIR")
+ "@lisparuga_datadir@/lisparuga"))
diff --git a/game.scm b/lisparuga/game.scm
index e08b110..d658419 100644
--- a/game.scm
+++ b/lisparuga/game.scm
@@ -14,25 +14,29 @@
;;; You should have received a copy of the GNU General Public License
;;; along with Lisparuga. If not, see <http://www.gnu.org/licenses/>.
-(use-modules (ice-9 format)
- (ice-9 match)
- (sly)
- (sly actor)
- (sly audio)
- (sly fps)
- (sly render framebuffer)
- (sly render sprite-batch)
- (sly render tileset)
- (srfi srfi-1)
- (lisparuga audio)
- (lisparuga bullets)
- (lisparuga enemies)
- (lisparuga explosions)
- (lisparuga player)
- (lisparuga stats)
- (lisparuga utils)
- (lisparuga view)
- (lisparuga world))
+(define-module (lisparuga game)
+ #:use-module (ice-9 format)
+ #:use-module (ice-9 match)
+ #:use-module (srfi srfi-1)
+ #:use-module (sly)
+ #:use-module (sly actor)
+ #:use-module (sly audio)
+ #:use-module (sly fps)
+ #:use-module (sly render framebuffer)
+ #:use-module (sly render sprite-batch)
+ #:use-module (sly render tileset)
+ #:use-module (lisparuga audio)
+ #:use-module (lisparuga bullets)
+ #:use-module (lisparuga enemies)
+ #:use-module (lisparuga explosions)
+ #:use-module (lisparuga player)
+ #:use-module (lisparuga stats)
+ #:use-module (lisparuga utils)
+ #:use-module (lisparuga view)
+ #:use-module (lisparuga world)
+ #:export (music
+ sound-effects
+ scene))
;;;
@@ -113,11 +117,11 @@
(define-signal font
(on-start
- (load-font "assets/fonts/kenpixel_mini.ttf" 7)))
+ (load-font* "kenpixel_mini.ttf" 7)))
(define-signal big-font
(on-start
- (load-font "assets/fonts/kenpixel_mini.ttf" 16)))
+ (load-font* "kenpixel_mini.ttf" 16)))
(define-signal fps-text
(signal-let ((fps fps)
@@ -208,27 +212,27 @@
render-nothing))))
(define-signal background
- (load-sprite/live "assets/images/background.png"
+ (load-sprite/live "background.png"
#:anchor 'bottom-left))
(define-signal background-overlay
- (load-sprite/live "assets/images/background-overlay.png"
+ (load-sprite/live "background-overlay.png"
#:anchor 'bottom-left))
(define-signal player-tileset
- (load-tileset/live "assets/images/player.png" 16 16))
+ (load-tileset/live "player.png" 16 16))
(define-signal bullet-tileset
- (load-tileset/live "assets/images/bullets.png" 16 16))
+ (load-tileset/live "bullets.png" 16 16))
(define-signal enemy-tileset
- (load-tileset/live "assets/images/enemies.png" 16 16))
+ (load-tileset/live "enemies.png" 16 16))
(define-signal explosion-tileset
- (load-tileset/live "assets/images/explosion.png" 16 16))
+ (load-tileset/live "explosion.png" 16 16))
(define-signal chain-tileset
- (load-tileset/live "assets/images/chain.png" 24 16))
+ (load-tileset/live "chain.png" 24 16))
(define-signal chain-sprite
(signal-map-maybe (lambda (world tileset)
@@ -323,26 +327,3 @@
(with-camera scaled-camera
(scale resolution-scale (render-sprite framebuffer-sprite)))))
render-nothing)))
-
-
-;;;
-;;; Main
-;;;
-
-(with-window (make-window #:title "lisparuga"
- #:resolution scaled-resolution)
- (enable-fonts)
- (enable-audio)
- (add-signal-hook! music loop-music)
- (add-signal-hook! sound-effects play-sound-effects)
- (add-hook! key-press-hook (lambda (key)
- (when (eq? key 'escape)
- (stop-game-loop))))
-
- (add-hook! window-close-hook stop-game-loop)
- (start-sly-repl)
- (run-game-loop scene))
-
-;;; Local Variables:
-;;; compile-command: "../pre-inst-env guile game.scm"
-;;; End:
diff --git a/lisparuga/view.scm b/lisparuga/view.scm
index e43d32e..3afda6c 100644
--- a/lisparuga/view.scm
+++ b/lisparuga/view.scm
@@ -30,6 +30,7 @@
#:use-module (sly signal)
#:use-module (sly utils)
#:use-module (lisparuga bullets)
+ #:use-module (lisparuga config)
#:use-module (lisparuga enemies)
#:use-module (lisparuga explosions)
#:use-module (lisparuga player)
@@ -41,6 +42,7 @@
camera
scaled-camera
font-color
+ load-font*
render-status-text
load-sprite/live
load-tileset/live
@@ -65,14 +67,26 @@
(define font-color (rgb #xdeeed6))
+(define (load-font* file size)
+ (load-font (string-append %datadir "/fonts/" file) size))
+
(define render-status-text
(memoize
(lambda (font text)
(render-sprite
(make-label font text #:blended? #f #:anchor 'center)))))
-(define load-sprite/live (with-live-reload load-sprite))
-(define load-tileset/live (with-live-reload load-tileset))
+(define (load-sprite* file . keyword-args)
+ (apply load-sprite
+ (string-append %datadir "/images/" file)
+ keyword-args))
+
+(define (load-tileset* file width height)
+ (load-tileset (string-append %datadir "/images/" file)
+ width height))
+
+(define load-sprite/live (with-live-reload load-sprite*))
+(define load-tileset/live (with-live-reload load-tileset*))
(define make-chain-sprite
(memoize
diff --git a/pre-inst-env.in b/pre-inst-env.in
index ae530ee..6deffcc 100644
--- a/pre-inst-env.in
+++ b/pre-inst-env.in
@@ -23,7 +23,10 @@ GUILE_LOAD_COMPILED_PATH="$abs_top_builddir${GUILE_LOAD_COMPILED_PATH:+:}$GUILE_
GUILE_LOAD_PATH="$abs_top_builddir:$abs_top_srcdir${GUILE_LOAD_PATH:+:}:$GUILE_LOAD_PATH"
export GUILE_LOAD_COMPILED_PATH GUILE_LOAD_PATH
-PATH="$abs_top_builddir:$PATH"
+PATH="$abs_top_builddir/scripts:$PATH"
export PATH
+LISPARUGA_DATADIR="$abs_top_builddir/assets"
+export LISPARUGA_DATADIR
+
exec "$@"
diff --git a/scripts/lisparuga.in b/scripts/lisparuga.in
new file mode 100644
index 0000000..21d1777
--- /dev/null
+++ b/scripts/lisparuga.in
@@ -0,0 +1,43 @@
+#!@GUILE@ --no-auto-compile
+-*- scheme -*-
+!#
+
+;;; Lisparuga
+;;; Copyright © 2016 David Thompson <davet@gnu.org>
+;;;
+;;; Lisparuga 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.
+;;;
+;;; Lisparuga 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 Lisparuga. If not, see <http://www.gnu.org/licenses/>.
+
+(use-modules (sly)
+ (sly audio)
+ (lisparuga audio)
+ (lisparuga game)
+ (lisparuga view))
+
+(with-window (make-window #:title "lisparuga"
+ #:resolution scaled-resolution)
+ (enable-fonts)
+ (enable-audio)
+ (add-signal-hook! music loop-music)
+ (add-signal-hook! sound-effects play-sound-effects)
+ (add-hook! key-press-hook (lambda (key)
+ (when (eq? key 'escape)
+ (stop-game-loop))))
+
+ (add-hook! window-close-hook stop-game-loop)
+ (start-sly-repl)
+ (run-game-loop scene))
+
+;;; Local Variables:
+;;; compile-command: "../pre-inst-env lisparuga"
+;;; End: