diff --git a/.gitignore b/.gitignore index 5dc83e0..9148070 100644 --- a/.gitignore +++ b/.gitignore @@ -1,9 +1,10 @@ -# ---> Scheme -*.ss~ -*.ss#* -.#*.ss - -*.scm~ -*.scm#* -.#*.scm - +*.go +/Makefile +/Makefile.in +/aclocal.m4 +/autom4te.cache/ +/build-aux/ +/config.log +/config.status +/configure +/pre-inst-env diff --git a/Makefile.am b/Makefile.am new file mode 100644 index 0000000..024fc0e --- /dev/null +++ b/Makefile.am @@ -0,0 +1,29 @@ +GOBJECTS = $(SOURCES:%.scm=%.go) +nobase_mod_DATA = $(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 +# +# for details. +guile_install_go_files = install-nobase_goDATA +$(guile_install_go_files): install-nobase_modDATA + +CLEANFILES = $(GOBJECTS) +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)/site-ccache + +SOURCES = \ + game/main.scm + +EXTRA_DIST = \ + $(SOURCES) \ + assets/images/chickadee.png \ + COPYING \ + README.md diff --git a/README.md b/README.md index f44acff..3f0e71c 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,53 @@ -# bloatrunner +# Chickadee Game Template -Small loderunner clone for the 2024 game jam \ No newline at end of file +This repository provides a template to use as a starting point for +making a new game using +[Chickadee](https://dthompson.us/projects/chickadee.html)! It +includes all the autotools boilerplate so you don't have to worry +about that nonsense too much. + +## Using Guix + +We *highly recommend* using [Guix](https://guix.gnu.org/) to manage +your development environment. Once Guix is installed, getting all of +the dependencies you need to develop is *easy*. Just run `guix shell` +from the root directory of this repository and you'll be good to go! + +## Building from source + +Assuming Guile and Chickadee are installed on your system, a fresh +project can be built like so: + +``` +./boostrap.sh +./configure +make -j$(nproc) +``` + +After the build system is initialized, only `make` needs to be run to +recompile the Scheme modules. + +## Running the game + +To run the game from the source checkout, use the `pre-inst-env` wrapper script: + +``` +./pre-inst-env run-game +``` + +## REPL-driven development + +After the game is launched, a Guile REPL server will be running on +port 37146. We recommend using the +[Geiser](https://geiser.nongnu.org/) Emacs extension for connecting to +it using `M-x connect-to-guile`. Once Geiser connects to the REPL, +the game can be modified while it runs! + +## Bundling + +If you are setup to produce redistributable bundles of Chickadee games +(see +https://dthompson.us/manuals/chickadee/Invoking-chickadee-bundle.html), +then you can use `chickadee bundle` to produce binary release bundles. +This is admittedly an area where things really do not "just work" as +they should, so do reach out for help if you need it. diff --git a/assets/images/chickadee.png b/assets/images/chickadee.png new file mode 100644 index 0000000..17a35e0 Binary files /dev/null and b/assets/images/chickadee.png differ diff --git a/assets/knight.png b/assets/images/knight.png similarity index 100% rename from assets/knight.png rename to assets/images/knight.png diff --git a/assets/lr_penguin2.png b/assets/images/lr_penguin2.png similarity index 100% rename from assets/lr_penguin2.png rename to assets/images/lr_penguin2.png diff --git a/assets/simples_pimples.png b/assets/images/simples_pimples.png similarity index 100% rename from assets/simples_pimples.png rename to assets/images/simples_pimples.png diff --git a/bootstrap.sh b/bootstrap.sh new file mode 100755 index 0000000..9b9eaf0 --- /dev/null +++ b/bootstrap.sh @@ -0,0 +1,3 @@ +#!/bin/sh + +exec autoreconf -vif diff --git a/bundle.scm b/bundle.scm new file mode 100644 index 0000000..59d3b4a --- /dev/null +++ b/bundle.scm @@ -0,0 +1,4 @@ +'((asset-directories . ("assets/images")) + (bundle-name . "chickadee-game-template-0.1.0-x86_64") + (code . "game/main.scm") + (launcher-name . "chickadee-game-template")) diff --git a/configure.ac b/configure.ac new file mode 100644 index 0000000..bafcb6d --- /dev/null +++ b/configure.ac @@ -0,0 +1,18 @@ +dnl -*- Autoconf -*- + +AC_INIT(chickadee-game-template, 0.1.0) +AC_CONFIG_SRCDIR(game) +AC_CONFIG_AUX_DIR([build-aux]) +AM_INIT_AUTOMAKE([foreign -Woverride -Wno-portability]) +AM_SILENT_RULES([yes]) + +AC_CONFIG_FILES([Makefile]) +AC_CONFIG_FILES([pre-inst-env], [chmod +x pre-inst-env]) +AC_CONFIG_FILES([scripts/run-game], [chmod +x scripts/run-game]) + +GUILE_PKG([3.0]) +GUILE_PROGS + +GUILE_MODULE_REQUIRED([chickadee]) + +AC_OUTPUT diff --git a/game/main.scm b/game/main.scm new file mode 100644 index 0000000..d2ee993 --- /dev/null +++ b/game/main.scm @@ -0,0 +1,38 @@ +;;; 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 (game main) + #:use-module (chickadee) + #:use-module (chickadee math vector) + #:use-module (chickadee graphics sprite) + #:use-module (chickadee graphics texture) + #:use-module (system repl coop-server) + #:export (launch-game)) + +(define sprite-position (vec2 256.0 176.0)) +(define sprite-texture #f) +(define repl #f) + +(define (load) + (set! sprite-texture (load-image "assets/images/chickadee.png")) + (set! repl (spawn-coop-repl-server))) + +(define (update _dt) + (poll-coop-repl-server repl)) + +(define (draw _alpha) + (draw-sprite sprite-texture sprite-position)) + +(define (launch-game args) + (run-game #:load load + #:update update + #:draw draw)) diff --git a/guix.scm b/guix.scm new file mode 100644 index 0000000..4399b8a --- /dev/null +++ b/guix.scm @@ -0,0 +1,29 @@ +(use-modules (guix packages) + ((guix licenses) #:prefix license:) + (guix download) + (guix git) + (guix build-system gnu) + (guix utils) + (gnu packages) + (gnu packages autotools) + (gnu packages guile) + (gnu packages game-development) + (gnu packages pkg-config)) + +(package + (name "chickadee-game-template") + (version "0.1.0-git") + (source (git-checkout (url (dirname (current-filename))))) + (build-system gnu-build-system) + (arguments + '(#:make-flags '("GUILE_AUTO_COMPILE=0"))) + (native-inputs + (list autoconf automake pkg-config)) + (inputs + (list guile-3.0)) + (propagated-inputs + (list guile-chickadee)) + (synopsis "Chickadee game template") + (description "This is an example package for a Chickadee game.") + (home-page "https://dthompson.us/projects/chickadee.html") + (license license:asl2.0)) diff --git a/pre-inst-env.in b/pre-inst-env.in new file mode 100644 index 0000000..881f142 --- /dev/null +++ b/pre-inst-env.in @@ -0,0 +1,10 @@ +#!/bin/sh + +abs_top_srcdir="`cd "@abs_top_srcdir@" > /dev/null; pwd`" +abs_top_builddir="`cd "@abs_top_builddir@" > /dev/null; pwd`" + +export GUILE_LOAD_COMPILED_PATH="$abs_top_builddir${GUILE_LOAD_COMPILED_PATH:+:}$GUILE_LOAD_COMPILED_PATH" +export GUILE_LOAD_PATH="$abs_top_builddir:$abs_top_srcdir${GUILE_LOAD_PATH:+:}:$GUILE_LOAD_PATH" +export PATH="$abs_top_builddir/scripts:$PATH" + +exec "$@" diff --git a/scripts/run-game.in b/scripts/run-game.in new file mode 100644 index 0000000..3a1020d --- /dev/null +++ b/scripts/run-game.in @@ -0,0 +1,7 @@ +#!@GUILE@ \ +--no-auto-compile -e main -s +!# + +(use-modules (game main)) +(define* (main #:optional (args (command-line))) + (launch-game args))