diff --git a/.guix/modules/bloatrunner.scm b/.guix/modules/bloatrunner.scm new file mode 100644 index 0000000..dacda63 --- /dev/null +++ b/.guix/modules/bloatrunner.scm @@ -0,0 +1,47 @@ + +(define-module (bloatrunner) + #:use-module (guix packages) + #:use-module ((guix licenses) #:prefix license:) + #:use-module (guix download) + #:use-module (guix gexp) + #:use-module (guix git-download) + #:use-module (guix git) + #:use-module (guix build-system gnu) + #:use-module (guix utils) + #:use-module (gnu packages) + #:use-module (gnu packages autotools) + #:use-module (gnu packages guile) + #:use-module (gnu packages game-development) + #:use-module (gnu packages pkg-config) + ) + + +(define vcs-file? + ;; Return true if the given file is under version control. + (or (git-predicate (dirname (dirname (current-source-directory)))) + (const #t))) ;not in a Git checkout + +(define-public bloatrunner + (package + (name "bloatrunner") + (version "0.1.0-git") + ;; (source (git-checkout (url (dirname (current-filename))))) + (source (local-file "../.." "guile-checkout" + #:recursive? #t + #:select? vcs-file?)) + (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 "Loderunner inspired game") + (description "Small game written for the 2024 lisp game jam.") + (home-page "https://www.snamellit.com/projects/bloatrunner.html") + (license license:gpl3))) + + +bloatrunner diff --git a/README.md b/README.md deleted file mode 100644 index 1b3ef61..0000000 --- a/README.md +++ /dev/null @@ -1,97 +0,0 @@ -# Bloatrunner - -A Lode Runner clone where you have to manage your waistline bloat. - -![Screenshot of Bloatrunner](assets/images/glamshot.png) - -As a *Bloatrunner* you have to collect keys to open the gate at the top of the level. However running costs energy, and as in any endurance event energy management and correct fueling is of utmost importance. By running your glycogen reserves in your muscles will deplete and need to be replenished either from food or from fat reserves. - -Your running kit has some small pockets to store a few gels or packets of gummi bears for fast energy replenishment. You will find replacements from time to time. In addition there will be other food items distributed over the levels. - -However as in real life it seems that most food items are unhealthy and for some reason irresistable so they are consumed immediately. Similarly for some reason it seems that food turns immediately into fat and takes forever to burn off. And too much fat makes you slow and even worse might make passing the finish gate a squeeze or plainly impossible. - -And then there are the _others_, which for some reason can run without getting tired, eat without getting fat, and generally make a nuisance of themselves. Close contact with these makes you lose the will to live and turns you into a couch potato, ceasing to be a _Bloatrunner_. - -A freak accident involving some radioactive meteorite allows you to create craters at will, well, more like potholes. But big enough to let the _others_ fall in so you can pass over their head. - -So now, go out, collect the keys and maintain a healthy diet! - -## 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! - -In a hosted guix you can ensure you are in your profile by setting the -environment in a `.envrc` file - -``` -export GUIX_PROFILE="/home/pti/.config/guix/current" -source "$GUIX_PROFILE/etc/profile" -export GUIX_LOCPATH="$HOME/.guix-profile/lib/locale" -use guix -l guix.scm - -``` - -## 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. - -Note: On hosted guix the configure script might find the host guile version -instead of the guix provided one. This can lead to incompatible bytecode errors. -To force to use a consistent guile use - -``` -./configure GUILE=$(which guile) -``` - -to ensure the right version is configured. - -## 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! - -When the environment is set as indicated above and the emacs direnv module -is enabled, we can run `geiser-guile` as usual and everything should work as -expected. - -To restart the game on crash I use *watchexec* to observe the folder and restart -on crash when the code is updated. That avoids scrolling errors so I can read the -error and immediately see if it is fixed on saving. - -``` -$ watchexec -e .scm ./pre-inst-env run-game -``` - - -## 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/README.org b/README.org new file mode 100644 index 0000000..501642b --- /dev/null +++ b/README.org @@ -0,0 +1,147 @@ +* Bloatrunner + +A Lode Runner clone where you have to manage your waistline bloat. + +![Screenshot of Bloatrunner](assets/images/glamshot.png) + +As a *Bloatrunner* you have to collect keys to open the gate at the top +of the level. However running costs energy, and as in any endurance +event energy management and correct fueling is of utmost +importance. By running your glycogen reserves in your muscles will +deplete and need to be replenished either from food or from fat +reserves. + +Your running kit has some small pockets to store a few gels or packets +of gummi bears for fast energy replenishment. You will find +replacements from time to time. In addition there will be other food +items distributed over the levels. + +However as in real life it seems that most food items are unhealthy +and for some reason irresistable so they are consumed +immediately. Similarly for some reason it seems that food turns +immediately into fat and takes forever to burn off. And too much fat +makes you slow and even worse might make passing the finish gate a +squeeze or plainly impossible. + +And then there are the _others_, which for some reason can run without +getting tired, eat without getting fat, voice their judgmental +opinions and generally make a nuisance of themselves. Close contact +with these makes you lose the will to live and turns you into a couch +potato, ceasing to be a _Bloatrunner_. + +A freak accident involving some radioactive meteorite allows you to +create craters at will, well, more like potholes. But big enough to +let the _others_ fall in so you can pass over their head. + +So now, go out, collect the keys and maintain a healthy diet! + + +* Game Plan [6/15] + + - [X] start project organization + - [X] select some assets to start with + - [X] animate hero + - [X] figure out tile maps + - [X] create hero entity + - [X] implement hero movement + - [ ] create other entity + - [ ] bundle game for distribution + - [ ] upload to itch.io + - [ ] automate upload to itch.io + - [ ] add keys and portal + - [ ] add foods and bloat indicator + - [ ] scale hero waist related to bloat level + - [ ] create more levels + - [ ] some level celebration/animation + +* Installation and Development + +** 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! + +In a hosted guix you can ensure you are in your profile by setting the +environment in a `.envrc` file + +``` +export GUIX_PROFILE="/home/pti/.config/guix/current" +source "$GUIX_PROFILE/etc/profile" +export GUIX_LOCPATH="$HOME/.guix-profile/lib/locale" +use guix -l guix.scm + +``` + +** 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. + +Note: On hosted guix the configure script might find the host guile +version instead of the guix provided one. This can lead to +incompatible bytecode errors. To force to use a consistent guile use + +``` +./configure GUILE=$(which guile) +``` + +to ensure the right version is configured. + +** 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! + +When the environment is set as indicated above and the emacs direnv +module is enabled, we can run `geiser-guile` as usual and everything +should work as expected. + +To restart the game on crash I use *watchexec* to observe the folder and +restart on crash when the code is updated. That avoids scrolling +errors so I can read the error and immediately see if it is fixed on +saving. + +``` +$ watchexec -e .scm ./pre-inst-env run-game +``` + + +** TODO Bundling + +Use `guix pack`. + +For this we need a proper package definition in a module with the +build instructions and sources and outputs. + +I followed the instructions at [[https://guix.gnu.org/en/blog/2023/from-development-environments-to-continuous-integrationthe-ultimate-guide-to-software-development-with-guix/][Ultimate Guide to Software Development +with Guix]] . + + + +#+BEGIN_SRC shell +guix pack -L .guix/modules bloatrunner +#+END_SRC + diff --git a/game/model/other.scm b/game/model/other.scm new file mode 100644 index 0000000..2d49f16 --- /dev/null +++ b/game/model/other.scm @@ -0,0 +1,73 @@ +;; Game state and logic for the hero entity +(define-module (game model hero) + #:use-module (ice-9 pretty-print) + #:use-module (srfi srfi-1) + #:use-module (srfi srfi-9) + #:use-module (srfi srfi-9 gnu) + #:use-module (srfi srfi-64) + #:use-module (chickadee math vector) + #:use-module (game util pipe) + #:use-module (game model level) + #:use-module (game model runner) + #:export (hero-load + hero-state + hero-bloat + hero-position + hero-x + hero-y + hero-update + )) + + +(define-immutable-record-type + (%make-hero runner bloat) + hero? + (runner hero-runner hero-with-runner) + (bloat hero-bloat hero-with-bloat) ;; 0.0 to 2.0, how much the hero is inflated + ) + +(define default-state 'fall) +(define default-bloat 1.0) + +(define (hero-load level) + "Create a hero at the position in the level map" + (let ((runner (runner-load (level-find-hero level)))) + (%make-hero runner default-bloat))) + +(define (hero-x hero) + "return the x coordinate as an integer" + (runner-x (hero-runner hero))) + +(define (hero-y hero) + "return the y coordinate as an integer" + (runner-y (hero-runner hero)) + ) + +(define (hero-state hero) + "return the current state of the hero" + (runner-state (hero-runner hero))) + +(define (hero-position hero) + "return the current position of the hero" + (runner-position (hero-runner hero))) + + +(define (hero-update hero level inputs dt) + (hero-with-runner hero (runner-update (hero-runner hero) level inputs dt))) + + + +;; Tests +[test-begin "hero-model"] + +(let* ((level (level-parse "WWWWW\nW...W\nW.P.W\nW..HW\nWWWWW\n")) + (hero (hero-load level)) + (default-position (level-find-hero level))) + (test-assert (hero? hero)) + (test-equal default-bloat (hero-bloat hero)) + + (test-equal 1.5 (hero-bloat (hero-with-bloat hero 1.5))) + (test-equal default-bloat (hero-bloat hero)) + + (test-end "hero-model")) + diff --git a/guix.scm b/guix.scm deleted file mode 100644 index dd5b4ea..0000000 --- a/guix.scm +++ /dev/null @@ -1,29 +0,0 @@ -(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 "bloatrunner") - (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 "Loderunner inspired game") - (description "Small game written for the 2024 lisp game jam.") - (home-page "https://www.snamellit.com/projects/bloatrunner.html") - (license license:gpl3)) diff --git a/guix.scm b/guix.scm new file mode 120000 index 0000000..945a01f --- /dev/null +++ b/guix.scm @@ -0,0 +1 @@ +.guix/modules/bloatrunner.scm \ No newline at end of file