diff options
-rw-r--r-- | .gitignore | 9 | ||||
-rw-r--r-- | Makefile.am | 43 | ||||
-rw-r--r-- | README | 50 | ||||
-rw-r--r-- | assets/fonts/kenpixel_mini.ttf | bin | 0 -> 26216 bytes | |||
-rw-r--r-- | assets/images/background-overlay.png | bin | 0 -> 749 bytes | |||
-rw-r--r-- | assets/images/background.png | bin | 0 -> 430 bytes | |||
-rw-r--r-- | assets/images/background.xcf | bin | 0 -> 60425 bytes | |||
-rw-r--r-- | assets/images/bullets.png | bin | 0 -> 305 bytes | |||
-rw-r--r-- | assets/images/bullets.xcf | bin | 0 -> 1013 bytes | |||
-rw-r--r-- | assets/images/db16_v1_analyze.png | bin | 0 -> 13342 bytes | |||
-rw-r--r-- | assets/images/enemies.png | bin | 0 -> 431 bytes | |||
-rw-r--r-- | assets/images/enemies.xcf | bin | 0 -> 1796 bytes | |||
-rw-r--r-- | assets/images/player.png | bin | 0 -> 538 bytes | |||
-rw-r--r-- | assets/images/player.xcf | bin | 0 -> 3046 bytes | |||
-rwxr-xr-x | bootstrap | 3 | ||||
-rw-r--r-- | configure.ac | 18 | ||||
-rw-r--r-- | game.scm | 519 | ||||
-rw-r--r-- | guix.scm | 174 | ||||
-rw-r--r-- | pre-inst-env.in | 30 |
19 files changed, 844 insertions, 2 deletions
diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..eaf7717 --- /dev/null +++ b/.gitignore @@ -0,0 +1,9 @@ +/pre-inst-env +/configure +/config.status +/config.log +/Makefile +/autom4te.cache +/build-aux +/Makefile.in +/aclocal.m4 diff --git a/Makefile.am b/Makefile.am new file mode 100644 index 0000000..5aa19b8 --- /dev/null +++ b/Makefile.am @@ -0,0 +1,43 @@ +## Copyright (C) 2016 David Thompson <davet@gnu.org> +## +## 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 +## <http://www.gnu.org/licenses/>. + +GOBJECTS = $(SOURCES:%.scm=%.go) + +nobase_mod_DATA = $(SOURCES) $(NOCOMP_SOURCES) +nobase_go_DATA = $(GOBJECTS) + +# Make sure source files are installed first, so that the mtime of +# installed compiled files is greater than that of installed source +# files. See +# <http://lists.gnu.org/archive/html/guile-devel/2010-07/msg00125.html> +# for details. +guile_install_go_files = install-nobase_goDATA +$(guile_install_go_files): install-nobase_modDATA + +EXTRA_DIST = $(SOURCES) $(NOCOMP_SOURCES) +GUILE_WARNINGS = -Wunbound-variable -Warity-mismatch -Wformat +SUFFIXES = .scm .go +.scm.go: + $(AM_V_GEN)$(top_builddir)/pre-inst-env $(GUILE_TOOLS) compile $(GUILE_WARNINGS) -o "$@" "$<" + +moddir=$(prefix)/share/guile/site/$(GUILE_EFFECTIVE_VERSION) +godir=$(libdir)/guile/$(GUILE_EFFECTIVE_VERSION)/ccache + +SOURCES = \ + sly/game.scm + +EXTRA_DIST += \ + pre-inst-env.in @@ -2,6 +2,52 @@ * Spring 2016 Lisp Game Jam -** Game +** Gameplay - Minimalistic Ikaruga clone with pixel art visuals. + Minimalistic Ikaruga clone. The player can switch between a light + ship and a dark ship with the push of a button. Bullets are either + light or dark. When the player is light, dark bullets kill and + light bullets are absorbed. Vice versa when the player is dark. + Dark bullets deal 2x damage to light enemies and vice versa. + + For simplicity, the player will fight waves of enemies with a boss + fight at the end. The next wave enters when the current wave has + been defeated. + +** Graphics + + All graphics use the Dawnbringer 16 color palette. + +*** Player sprite + + The player sprite is 16x16 and has 3 frames: moving forward, + moving left, moving right. + +*** Enemy sprites + + Each enemy sprite has only 3 frames. The first two are the normal + sprite frames. Two frames are used so that the enemy can + "breathe" and appear as if it's moving and isn't just static. The + third frame is flashed when the enemy has been hit by a bullet. + +*** Explosion sprites + + Need both small and large explosion animations. Perhaps some + explosion animation on OpenGameArt can be recolored. + +** Design resources + + http://shmuptheory.blogspot.com/2010/02/anatomy-of-shmup.html + http://www.gamasutra.com/blogs/AttilioCarotenuto/20150930/254963/Designing_smart_meaningful_SHMUPs.php + + +** Devlog + + (aggregate into real blog post at some point) + +*** Day 1 + + - Made player sprite + - Made first enemy sprite + - Made scrolling background + - Got boilerplate code in place, player can move and shoot. diff --git a/assets/fonts/kenpixel_mini.ttf b/assets/fonts/kenpixel_mini.ttf Binary files differnew file mode 100644 index 0000000..ceb2b41 --- /dev/null +++ b/assets/fonts/kenpixel_mini.ttf diff --git a/assets/images/background-overlay.png b/assets/images/background-overlay.png Binary files differnew file mode 100644 index 0000000..5629472 --- /dev/null +++ b/assets/images/background-overlay.png diff --git a/assets/images/background.png b/assets/images/background.png Binary files differnew file mode 100644 index 0000000..f0e1f58 --- /dev/null +++ b/assets/images/background.png diff --git a/assets/images/background.xcf b/assets/images/background.xcf Binary files differnew file mode 100644 index 0000000..bc5d985 --- /dev/null +++ b/assets/images/background.xcf diff --git a/assets/images/bullets.png b/assets/images/bullets.png Binary files differnew file mode 100644 index 0000000..7a28c67 --- /dev/null +++ b/assets/images/bullets.png diff --git a/assets/images/bullets.xcf b/assets/images/bullets.xcf Binary files differnew file mode 100644 index 0000000..5899669 --- /dev/null +++ b/assets/images/bullets.xcf diff --git a/assets/images/db16_v1_analyze.png b/assets/images/db16_v1_analyze.png Binary files differnew file mode 100644 index 0000000..aa8eb3a --- /dev/null +++ b/assets/images/db16_v1_analyze.png diff --git a/assets/images/enemies.png b/assets/images/enemies.png Binary files differnew file mode 100644 index 0000000..7970539 --- /dev/null +++ b/assets/images/enemies.png diff --git a/assets/images/enemies.xcf b/assets/images/enemies.xcf Binary files differnew file mode 100644 index 0000000..92f56b1 --- /dev/null +++ b/assets/images/enemies.xcf diff --git a/assets/images/player.png b/assets/images/player.png Binary files differnew file mode 100644 index 0000000..9e0594e --- /dev/null +++ b/assets/images/player.png diff --git a/assets/images/player.xcf b/assets/images/player.xcf Binary files differnew file mode 100644 index 0000000..6dd242a --- /dev/null +++ b/assets/images/player.xcf diff --git a/bootstrap b/bootstrap new file mode 100755 index 0000000..e756b42 --- /dev/null +++ b/bootstrap @@ -0,0 +1,3 @@ +#! /bin/sh + +autoreconf -vif diff --git a/configure.ac b/configure.ac new file mode 100644 index 0000000..17f3b69 --- /dev/null +++ b/configure.ac @@ -0,0 +1,18 @@ +dnl -*- Autoconf -*- + +AC_INIT(lispgamejam, 0.1.0) +AC_CONFIG_SRCDIR(gamejam) +AC_CONFIG_AUX_DIR([build-aux]) +AM_INIT_AUTOMAKE([color-tests -Wall -Wno-portability foreign]) +AM_SILENT_RULES([yes]) + +AC_PATH_PROG([GUILE], [guile]) +AC_CONFIG_FILES([Makefile]) +AC_CONFIG_FILES([pre-inst-env], [chmod +x pre-inst-env]) + +GUILE_PKG([2.2 2.0]) +GUILE_PROGS + +GUILE_MODULE_REQUIRED([sly]) + +AC_OUTPUT diff --git a/game.scm b/game.scm new file mode 100644 index 0000000..1616398 --- /dev/null +++ b/game.scm @@ -0,0 +1,519 @@ +;;; Sly +;;; Copyright (C) 2016 David Thompson <dthompson2@worcester.edu> +;;; +;;; 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 +;;; <http://www.gnu.org/licenses/>. + +(use-modules (ice-9 match) + (sly) + (sly actor) + (sly fps) + (sly live-reload) + ((sly math vector) #:select (magnitude) #:prefix v:) + (sly records) + (sly render framebuffer) + (sly render sprite-batch) + (sly render tileset) + (srfi srfi-1) + (srfi srfi-9) + (srfi srfi-11)) + + +;;; +;;; Model +;;; + +(define resolution (vector2 120 160)) +(define bounds (make-rect (vector2 0 0) resolution)) +(define player-bounds (rect-inflate bounds -6 -8)) +(define bullet-bounds (rect-inflate bounds 32 32)) +(define player-speed 1.1) + +(define origin2 (vector2 0 0)) + +(define-record-type* <bullet> + %make-bullet make-bullet + bullet? + (type bullet-type 'generic) + (live? bullet-live? #t) + (position bullet-position origin2) + (direction bullet-direction 0)) + +(define-record-type* <player> + %make-player make-player + player? + (position player-position (vector2 (/ (vx resolution) 2) 4)) + (direction player-direction (vector2 0 0)) + (shooting? player-shooting? #f) + (hitbox player-hitbox (make-rect -1 1 2 2)) + (lives player-lives 3) + (score player-score 0)) + +(define-record-type* <enemy> + %make-enemy make-enemy + enemy? + (position enemy-position origin2) + (type enemy-type 'generic) + (hitbox enemy-hitbox (make-rect -3 -3 6 6)) + (health enemy-health 0)) + +(define-record-type* <world> + %make-world make-world + world? + (player world-player (make-actor (make-player) idle)) + (player-bullets world-player-bullets '()) + (enemies world-enemies '()) + (enemy-bullets world-enemy-bullets '())) + +(define (player-dead? player) + (zero? (player-lives player))) + +(define (enemy-dead? enemy) + (zero? (enemy-health enemy))) + +(define (enemy-alive? enemy) + (> (enemy-health enemy) 0)) + +(define (kill-bullet bullet) + (make-bullet #:inherit bullet #:live? #f)) + +(define (move-bullet bullet offset) + (make-bullet #:inherit bullet + #:position (v+ (bullet-position bullet) offset))) + +(define (move-bullet-to bullet position) + (make-bullet #:inherit bullet #:position position)) + +(define (bullet-in-bounds? bullet) + (rect-contains? bullet-bounds (bullet-position bullet))) + +(define (forward speed) + (lambda (world effects bullet) + (values #f + effects + (move-bullet bullet (polar2 speed (bullet-direction bullet)))))) + +(define (direct-player player direction) + (make-player #:inherit player #:direction direction)) + +(define (move-player player offset) + (make-player #:inherit player + #:position (rect-clamp player-bounds + (v+ (player-position player) offset)))) + +(define (set-player-shooting player shooting?) + (make-player #:inherit player #:shooting? shooting?)) + +(define (player-forward speed) + (lambda (world effects player) + (values #f + effects + (move-player player (v* speed (player-direction player)))))) + +(define player-bullet-script + (forever (forward 4))) + +(define player-bullet-direction (/ pi 2)) + +(define (make-player-bullet player offset) + (make-actor (make-bullet #:position (v+ (player-position player) offset) + #:direction player-bullet-direction) + player-bullet-script)) + +(define (add-player-bullets world bullets) + (make-world #:inherit world + #:player-bullets + (append bullets (world-player-bullets world)))) + +(define (player-shoot world player) + (add-player-bullets world + (list + (make-player-bullet player (vector2 -2 1)) + (make-player-bullet player (vector2 4 1))))) + +(define (move-enemy enemy offset) + (make-enemy #:inherit enemy + #:position (v+ (enemy-position enemy) offset))) + +(define (add-enemy-bullets world bullets) + (make-world #:inherit world + #:enemy-bullets + (append bullets (world-enemy-bullets world)))) + +(define (simple-enemy-bullet position direction speed) + (make-actor (make-bullet #:type 'enemy-basic + #:position position + #:direction direction) + (forever (forward speed)))) + +(define (enemy-shoot world enemy direction speed) + (let ((position (enemy-position enemy))) + (add-enemy-bullets world + (list + (simple-enemy-bullet position direction speed))))) + +(define (enemy-shoot-at-player world enemy speed) + (let* ((v (normalize + (v- (enemy-position enemy) + (player-position + (actor-ref + (world-player world)))))) + (direction (+ pi (atan (vy v) (vx v)))) + (position (enemy-position enemy)) + (bullets + (list (simple-enemy-bullet position (+ direction (/ pi 16)) speed) + (simple-enemy-bullet position (+ direction (/ pi 8)) speed) + (simple-enemy-bullet position direction speed) + (simple-enemy-bullet position (- direction (/ pi 8)) speed) + (simple-enemy-bullet position (- direction (/ pi 16)) speed)))) + (add-enemy-bullets world bullets))) + +(define (keep-bullet? bullet) + (and (bullet-live? bullet) + (bullet-in-bounds? bullet))) + +(define (update-bullets effects world bullets) + ;; TODO: Gather effects + (values effects + (filter-map (lambda (actor) + (let-values (((effects new-actor) + (update-actor world '() actor))) + (let ((bullet (actor-ref new-actor))) + (and (bullet-live? bullet) + (bullet-in-bounds? bullet) + new-actor)))) + bullets))) + +(define (update-enemies effects world) + ;; TODO: gather effects + (let-values (((new-effects new-enemies) + (actor-filter-update enemy-alive? world (world-enemies world)))) + (values (append new-effects effects) new-enemies))) + +(define (update-player effects world) + (update-actor world effects (world-player world))) + +(define (update-world world) + ;; TODO: collision detection + (let*-values + (((effects new-player) (update-player '() world)) + ((effects new-enemies) (update-enemies effects world)) + ((effects new-player-bullets) + (update-bullets effects world (world-player-bullets world))) + ((effects new-enemy-bullets) + (update-bullets effects world (world-enemy-bullets world)))) + (apply-effects effects + (make-world #:player new-player + #:player-bullets new-player-bullets + #:enemies new-enemies + #:enemy-bullets new-enemy-bullets)))) + +(define (world-eval exp world) + (match exp + (('null) world) + (('tick time) + (update-world world)) + (('player-direction direction) + (make-world #:inherit world + #:player (call-with-actor (world-player world) + (lambda (player) + (direct-player player direction))))) + (('player-shoot shooting?) + (make-world #:inherit world + #:player (call-with-actor (world-player world) + (lambda (player) + (set-player-shooting player shooting?))))))) + +(define player-shoot* (action-effect-lift player-shoot)) +(define move-enemy* (action-lift move-enemy)) +(define enemy-shoot* (action-effect-lift enemy-shoot)) +(define enemy-shoot-at-player* (action-effect-lift enemy-shoot-at-player)) + +(define %default-player + (make-actor (make-player) + (forever + (both (repeat 3 (player-forward player-speed)) + (whena player-shooting? (player-shoot*)))))) + +(define %default-enemy + (make-actor (make-enemy #:position (vector2 60 120) + #:health 100) + (let ((v (vector2 .8 0)) + (bullet-speed 0.6) + (interval 15)) + (forever + (sequence + (repeat interval (move-enemy* v)) + (enemy-shoot-at-player* bullet-speed) + (repeat interval (move-enemy* (v- v))) + (enemy-shoot-at-player* bullet-speed) + (repeat interval (move-enemy* (v- v))) + (enemy-shoot-at-player* bullet-speed) + (repeat interval (move-enemy* v)) + (enemy-shoot-at-player* bullet-speed)))))) + + +;;; +;;; Controller +;;; + +(define-signal timer (signal-timer)) + +(define-signal world + (signal-fold world-eval + (make-world #:player %default-player + #:enemies (list %default-enemy)) + (signal-merge + (make-signal '(null)) + (signal-let ((time timer)) + `(tick ,time)) + (signal-let ((direction key-arrows)) + `(player-direction ,direction)) + (signal-let ((shoot? (signal-drop-repeats (key-down? 'z)))) + `(player-shoot ,shoot?))))) + +(define (key-toggle key) + "Create a signal that is initially #f and toggles between #t and #f +each time KEY is pressed." + (signal-fold (lambda (down? previous) + (and down? (not previous))) + #f + (signal-filter identity #f + ;; Ignore repeated key down signals. + (signal-drop-repeats (key-down? key))))) + +(define-signal display-fps? (key-toggle 'f)) + + +;;; +;;; View +;;; + +(define resolution-scale 4) +(define scaled-resolution (v* resolution resolution-scale)) + +(define camera + (2d-camera #:area (make-rect 0 0 (vx resolution) (vy resolution)))) + +(define scaled-camera + (2d-camera #:area (make-rect 0 0 + (vx scaled-resolution) + (vy scaled-resolution)))) + +(define-signal framebuffer + (on-start + (make-framebuffer (vx scaled-resolution) (vy scaled-resolution)))) + +(define-signal framebuffer-sprite + (signal-map-maybe (lambda (framebuffer) + (make-sprite (framebuffer-texture framebuffer) + #:anchor 'bottom-left)) + framebuffer)) + +(define-signal font + (on-start + (load-font "assets/fonts/kenpixel_mini.ttf" 7))) + +(define font-color (rgb #xdeeed6)) + +(define-signal fps-text + (signal-let ((fps fps) + (font font)) + (if font + (move (vector2 (vx resolution) 0) + (render-sprite + (make-label font (format #f "~d fps" fps) + #:blended? #f + #:anchor 'bottom-right))) + render-nothing))) + +(define-signal score-text + (signal-let ((font font)) + (if font + (move resolution + (render-sprite + (make-label font "123456789" + #:blended? #f + #:anchor 'top-right))) + render-nothing))) + +(define-signal lives-text + (signal-let ((font font)) + (if font + (move origin2 + (render-sprite + (make-label font "3 ship" + #:blended? #f + #:anchor 'bottom-left))) + render-nothing))) + +(define-signal chain-text + (signal-let ((font font)) + (if font + (move (vector2 0 (vy resolution)) + (render-sprite + (make-label font "0 chain" + #:blended? #f + #:anchor 'top-left))) + render-nothing))) + +(define load-sprite/live (with-live-reload load-sprite)) +(define load-tileset/live (with-live-reload load-tileset)) + +(define-signal background + (load-sprite/live "assets/images/background.png" + #:anchor 'bottom-left)) + +(define-signal background-overlay + (load-sprite/live "assets/images/background-overlay.png" + #:anchor 'bottom-left)) + +(define-signal player-tileset + (load-tileset/live "assets/images/player.png" 16 16)) + +(define-signal bullet-tileset + (load-tileset/live "assets/images/bullets.png" 16 16)) + +(define-signal enemy-tileset + (load-tileset/live "assets/images/enemies.png" 16 16)) + +(define-signal player-sprite + (signal-map-maybe (lambda (tileset) + (make-sprite (tileset-ref tileset 12))) + player-tileset)) + +(define (make-scrolling-background background time speed) + (signal-let ((background background) + (time timer)) + (if background + (let* ((height (vy resolution)) + (y (- (* (modulo time (round (/ height speed))) speed))) + (render (render-sprite background))) + (render-begin + (move (vector2 0 y) render) + (move (vector2 0 (+ y height)) render))) + render-nothing))) + +(define (render-sprite-maybe sprite) + (signal-map (lambda (sprite) + (if sprite + (render-sprite sprite) + render-nothing)) + sprite)) + +(define-signal scrolling-background + (signal-map render-begin + ;;(make-scrolling-background background timer 0.2) + (render-sprite-maybe background) + (make-scrolling-background background-overlay timer 4))) + +(define-signal batch + (on-start (make-sprite-batch 1000))) + +(define bullet-rect (make-rect -8 -8 16 16)) +(define enemy-rect (make-rect -8 -8 16 16)) + +(define (render-bullets bullets tileset batch) + (lambda (context) + (with-sprite-batch batch context + (for-each (lambda (actor) + (let* ((bullet (actor-ref actor)) + (rect (rect-move bullet-rect + (bullet-position bullet))) + (tex (tileset-ref tileset + (match (bullet-type bullet) + ('generic 12) + ('enemy-basic 13))))) + (sprite-batch-add! batch context tex rect))) + bullets)))) + +(define (render-enemies enemies tileset batch) + (lambda (context) + (with-sprite-batch batch context + (for-each (lambda (actor) + (let* ((enemy (actor-ref actor)) + (rect (rect-move enemy-rect (enemy-position enemy))) + (tex (tileset-ref tileset + (match (enemy-type enemy) + ('generic 12))))) + (sprite-batch-add! batch context tex rect))) + enemies)))) + +(define-signal scene + (signal-let ((fps-text fps-text) + (score-text score-text) + (lives-text lives-text) + (chain-text chain-text) + (display-fps? display-fps?) + (background scrolling-background) + (framebuffer framebuffer) + (framebuffer-sprite framebuffer-sprite) + (player-sprite player-sprite) + (bullet-tileset bullet-tileset) + (enemy-tileset enemy-tileset) + (batch batch) + (world world)) + (if (and framebuffer framebuffer-sprite batch bullet-tileset + enemy-tileset player-sprite) + (let ((player (actor-ref (world-player world)))) + (render-begin + (with-framebuffer framebuffer + (with-camera camera + (render-begin + background + (render-bullets (world-player-bullets world) + bullet-tileset + batch) + (move (player-position player) + (render-sprite player-sprite)) + (render-bullets (world-enemy-bullets world) + bullet-tileset + batch) + (render-enemies (world-enemies world) + enemy-tileset + batch) + (with-color font-color + (render-begin + (if display-fps? + fps-text + render-nothing) + score-text + lives-text + chain-text))))) + (with-camera scaled-camera + (scale resolution-scale (render-sprite framebuffer-sprite))))) + render-nothing))) + + +;;; +;;; Main +;;; + +(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) + +(enable-fonts) + +(with-window (make-window #:title "binarium" + #:resolution scaled-resolution) + (run-game-loop scene)) + +;;; Local Variables: +;;; compile-command: "../pre-inst-env guile simple.scm" +;;; End: diff --git a/guix.scm b/guix.scm new file mode 100644 index 0000000..555a7bf --- /dev/null +++ b/guix.scm @@ -0,0 +1,174 @@ +;;; Sly +;;; Copyright (C) 2014, 2015 David Thompson <davet@gnu.org> +;;; +;;; Sly 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. +;;; +;;; Sly 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 +;;; <http://www.gnu.org/licenses/>. + +;;; Commentary: +;; +;; Development environment for GNU Guix. +;; +;; 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) +;; +;; To build the development snapshot, run: +;; +;; guix build -f guix.scm +;; +;; To install the development snapshot, run: +;; +;; guix install -f guix.scm +;; +;;; Code: + +(use-modules (ice-9 match) + (srfi srfi-1) + (guix packages) + (guix licenses) + (guix git-download) + (guix build-system gnu) + (gnu packages) + (gnu packages autotools) + (gnu packages pkg-config) + (gnu packages texinfo) + (gnu packages guile) + (gnu packages gl) + (gnu packages sdl) + (gnu packages maths) + (gnu packages image)) + +(define (package-with-guile p guile) + (package + (inherit p) + (inputs + (map (match-lambda + (("guile" _) + `("guile" ,guile)) + (input input)) + (package-inputs p))))) + +(define (package-with-guile-next p) + (package-with-guile p guile-next)) + +(define guile-sdl2 + (package + (name "guile-sdl2") + (version "0.1.0") + (source (origin + (method git-fetch) + (uri (git-reference + (url "git://dthompson.us/guile-sdl2.git") + (commit "55c4eef"))) + (sha256 + (base32 + "1yckf6n2iwp5l3yz4y0rks5qbylnmfnpcxmlwl74aqyqfxd586ix")))) + (build-system gnu-build-system) + (arguments + '(#:configure-flags + (list (string-append "--with-libsdl2-prefix=" + (assoc-ref %build-inputs "sdl2")) + (string-append "--with-libsdl2-image-prefix=" + (assoc-ref %build-inputs "sdl2-image")) + (string-append "--with-libsdl2-ttf-prefix=" + (assoc-ref %build-inputs "sdl2-ttf")) + (string-append "--with-libsdl2-mixer-prefix=" + (assoc-ref %build-inputs "sdl2-mixer"))) + #:make-flags '("GUILE_AUTO_COMPILE=0") + #:phases + (modify-phases %standard-phases + (add-after 'unpack 'bootstrap + (lambda _ (zero? (system* "sh" "bootstrap")))) + (add-after 'configure 'patch-makefile + (lambda _ + ;; Install compiled Guile files in the expected place. + (substitute* '("Makefile") + (("^godir = .*$") + "godir = $(moddir)\n"))))))) + (native-inputs + `(("autoconf" ,autoconf) + ("automake" ,automake) + ("pkg-config" ,pkg-config))) + (inputs + `(("guile" ,guile-next) + ("sdl2" ,sdl2) + ("sdl2-image" ,sdl2-image) + ("sdl2-mixer" ,sdl2-mixer) + ("sdl2-ttf" ,sdl2-ttf))) + (synopsis "Guile bindings for SDL2") + (description "Guile-sdl2 provides pure Guile Scheme bindings to the +SDL2 C shared library via the foreign function interface.") + (home-page "https://git.dthompson.us/guile-sdl2.git") + (license lgpl3+))) + +(define sly + (package + (name "sly") + (version "0.1") + (source (origin + (method git-fetch) + (uri (git-reference + (url "git://dthompson.us/sly.git") + (commit "55593075e50876ee9d98508687b0408effbcc8ef"))) + (sha256 + (base32 + "051x9y0isrsynjr217gd58b1r3jspd3kjl07zda8cy1nfnjmxwb6")))) + (build-system gnu-build-system) + (arguments + '(#:phases + (modify-phases %standard-phases + (add-after 'unpack 'bootstrap + (lambda _ (zero? (system* "sh" "bootstrap"))))))) + (native-inputs + `(("pkg-config" ,pkg-config) + ("autoconf" ,autoconf) + ("automake" ,automake) + ("texinfo" ,texinfo))) + (propagated-inputs + `(("guile-sdl2" ,guile-sdl2) + ("guile-opengl" ,(package-with-guile-next guile-opengl)))) + (inputs + `(("guile" ,guile-next) + ("mesa" ,mesa))) + (synopsis "2D/3D game engine for GNU Guile") + (description "Sly is a 2D/3D game engine written in Guile Scheme. +Sly differs from most game engines in that it emphasizes functional +reactive programming and live coding.") + (home-page "http://dthompson.us/pages/software/sly.html") + (license gpl3+) + (native-search-paths + (list (search-path-specification + (variable "SLY_DATADIR") + (files '("share/sly"))))))) + +(package + (name "lisp-game-jam-spring-2016") + (version "0.1") + (source #f) + (build-system gnu-build-system) + (native-inputs + `(("pkg-config" ,pkg-config) + ("autoconf" ,autoconf) + ("automake" ,automake))) + (inputs + `(("guile" ,guile-next))) + (propagated-inputs + `(("sly" ,sly))) + (synopsis "Spring 2016 Lisp Game Jam") + (description "Spring 2016 Lisp Game Jam") + (home-page "https://git.dthompson.us/lisp-game-jam-2016-spring.git") + (license gpl3+)) diff --git a/pre-inst-env.in b/pre-inst-env.in new file mode 100644 index 0000000..77d8168 --- /dev/null +++ b/pre-inst-env.in @@ -0,0 +1,30 @@ +#!/bin/sh + +# Sly +# Copyright © 2016 David Thompson <dthompson2@worcester.edu> +# +# Sly 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 +# <http://www.gnu.org/licenses/>. + +abs_top_srcdir="`cd "@abs_top_srcdir@" > /dev/null; pwd`" +abs_top_builddir="`cd "@abs_top_builddir@" > /dev/null; pwd`" + +GUILE_LOAD_COMPILED_PATH="$abs_top_builddir${GUILE_LOAD_COMPILED_PATH:+:}$GUILE_LOAD_COMPILED_PATH" +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" +export PATH + +exec "$@" |