From e992bd986fdbf28c69c69198ec1c0de8e2f14e56 Mon Sep 17 00:00:00 2001 From: Peter Tillemans Date: Mon, 27 May 2024 13:06:56 +0200 Subject: [PATCH] some level tweaks --- README.org | 15 ++++++++++++--- assets/levels/level-001.map | 2 +- assets/levels/level-002.map | 10 +++++----- game/model/hero.scm | 16 ++++++++++------ game/render/level.scm | 14 +++++++------- game/util/assets.scm | 22 ++++++++++++++++++++-- publish.in | 2 +- 7 files changed, 56 insertions(+), 25 deletions(-) diff --git a/README.org b/README.org index b595508..fc9aa0a 100644 --- a/README.org +++ b/README.org @@ -36,7 +36,7 @@ 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 [20/22] +* Game Plan [20/25] - [X] start project organization - [X] select some assets to start with @@ -60,6 +60,9 @@ So now, go out, collect the keys and maintain a healthy diet! - [X] add foods and bloat indicator - [X] scale hero waist related to bloat level - [X] create more levels + - [ ] slow down if hungry or had too much to eat + - [ ] add more text to explain things + - [ ] add text bubbles with unhelpful comments - [ ] dig potholes - [ ] make others steal keys - [X] some level celebration/animation @@ -79,7 +82,7 @@ Untar the filename, enter the newly created folder and launch `bloatrunner/bloat #+END_SRC -*** TODO make an upload script which cleans up the filename +*** DONE make an upload script which cleans up the filename The current filename contains the GUIX UUID which is ugly and not very userfriendly. @@ -163,7 +166,7 @@ $ watchexec -e .scm ./pre-inst-env bloatrunner ``` -** TODO Bundling +** DONE Bundling Use `guix pack`. @@ -257,6 +260,12 @@ the environment variables set according to the installed environment. most of this is dynamically construct the content of the paths. +** Publishing to Itch.io + +The autoconf also creates a `publish` script to create a distribution +and upload to itch.io. + + * Asset Dependencies ** Hero sprites diff --git a/assets/levels/level-001.map b/assets/levels/level-001.map index 1050d12..0aba84f 100644 --- a/assets/levels/level-001.map +++ b/assets/levels/level-001.map @@ -5,7 +5,7 @@ WWWWWGWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWW W H W W O H O W -W H K F K f K F F H W +W H K K F K F H W W O BBBBBBBBBBBBBBBBBBBBBBBBBBHB O W - W H W W H W diff --git a/assets/levels/level-002.map b/assets/levels/level-002.map index 1100cd6..0886132 100644 --- a/assets/levels/level-002.map +++ b/assets/levels/level-002.map @@ -5,15 +5,15 @@ WWWWWWWWWWWWWWWWWWWGWWWWWWWWWWWWWWWWWWWW W H W W O H O W -W H K H K H W +W H F K F H K F H W W O BHBBBBBBBBBBBBBBBBBBBBBBBBH O W - W HH H W W HHH H W W HHHH H H W -W BBBBHHHH BBBBBBBHB W +W BBBHHHH BBBBBBBHB W W HHHH HHHH W - W HHHH HHHH W -W H K HHHHHHHHHHHH HHHH W +W H K HHHHHHHHHHHH F f HHHH W W BHBBBB HHHHHHHHHHHHHHHHHHHH W W H HH W W H HH W - @@ -21,7 +21,7 @@ W H HH W W H HH W W H H W W H H W -W H H H K H W - +W H H H KFFH W - W BBBBBBBBBHB P BHBBBBBBB W W H H W W H H W @@ -29,6 +29,6 @@ W H H W W BHBBBBBBBBBBBHB W - W H H W W H H W -W H K H W +W H F K f H W WBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBW WWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWW - \ No newline at end of file diff --git a/game/model/hero.scm b/game/model/hero.scm index 29db12e..120d99f 100644 --- a/game/model/hero.scm +++ b/game/model/hero.scm @@ -55,16 +55,16 @@ "return the current position of the hero" (runner-position (hero-runner hero))) +(define (clamp lower upper x) + "return x clamped to the given lower and upper bounds" + (min upper (max lower x))) + (define (hero-bloat hero) "return the current bloat of the hero clamped to 0.5 and 2.0" (let* ((calories (- (hero-eaten hero) (hero-exercise hero))) (raw-bloat (+ 1.0 (/ calories 2000.0))) ) - (cond - ((< calories -1000) 0.5) - ((> calories 1000) 2.0) - (else raw-bloat) - ))) + (clamp 0.5 2.0 raw-bloat))) (define (collides? a b) "return true if the position collides with the given position" @@ -83,12 +83,12 @@ (define moving-exercise 0.2) (define (calculate-exercise hero new-position) + "return the calories burned for the hero moving to the new position" (let ((movement (vec2- new-position (hero-position hero)))) (+ (if (> (vec2-y movement) 0) climbing-exercise 0) (if (not (zero? (vec2-x movement))) moving-exercise 0)))) - (define (hero-update hero level inputs keys calories-eaten dt) (let* ((new-runner (runner-update (hero-runner hero) level inputs dt)) (new-runner (if (blocked-by-door? @@ -131,6 +131,10 @@ (test-assert (not (blocked-by-door? level '(dummy-key) (vec2- goal-position (vec2 0 -16)) 1.0))) (test-assert (blocked-by-door? level '() goal-position 1.55)) + (test-equal 0.5 (clamp 0.5 2.0 0.0 )) + (test-equal 1.5 (clamp 0.5 2.0 1.5)) + (test-equal 2.0 (clamp 0.5 2.0 2.5)) + ) (test-end "hero-model") diff --git a/game/render/level.scm b/game/render/level.scm index 6c1aa80..b307869 100644 --- a/game/render/level.scm +++ b/game/render/level.scm @@ -72,20 +72,20 @@ #:texture-region texture-region))) (iota (level-width level) 0))) (iota (level-height level) 0))) - + ;; render the level tiles - (define (render-level-draw level) - (draw-sprite-batch sprite-batch)) +(define (render-level-draw level) + (draw-sprite-batch sprite-batch)) (define (render-victory) - (draw-sprite (assets-load-image "victory.jpg") (vec2 0 0))) + (draw-sprite victory-image (vec2 0 0))) (define (render-defeat) - (draw-sprite (assets-load-image "defeat.jpg") (vec2 0 0))) + (draw-sprite defeat-image (vec2 0 0))) -(test-begin "tile translation") +(test-begin "tile-translation") (test-equal (level-tile-index 'empty) empty-index) (test-equal (level-tile-index 'brick) 3750) @@ -94,4 +94,4 @@ (test-equal (level-tile-index 'goal) empty-index) (test-equal (level-tile-index 'unknown) 3326) -(test-end "tile translation") +(test-end "tile-translation") diff --git a/game/util/assets.scm b/game/util/assets.scm index adf64ce..1bd3c73 100644 --- a/game/util/assets.scm +++ b/game/util/assets.scm @@ -3,7 +3,18 @@ #:use-module (ice-9 textual-ports) #:use-module (chickadee graphics texture) #:use-module (chickadee graphics color) - #:export (assets-load assets-load-image tile-texture tile-atlas hero-texture hero-atlas assets-map-levels read-level-map) + #:export ( + assets-load + assets-load-image + tile-texture + tile-atlas + hero-texture + hero-atlas + assets-map-levels + read-level-map + defeat-image + victory-image + ) ) @@ -13,6 +24,9 @@ (define hero-texture #f) (define hero-atlas #f) +(define defeat-image #f) +(define victory-image #f) + (define (assets-location) "find the location of the assets directory. The location is specified by the ASSET_DIR environment variable, or defaults to 'assets' in the @@ -58,4 +72,8 @@ (set! tile-atlas (split-texture tile-texture 16 16)) (set! hero-texture (assets-load-image "lr_penguin2.png")) - (set! hero-atlas (split-texture hero-texture 32 32))) + (set! hero-atlas (split-texture hero-texture 32 32)) + + (set! defeat-image (assets-load-image "defeat.jpg")) + (set! victory-image (assets-load-image "victory.jpg")) + ) diff --git a/publish.in b/publish.in index 2bb094a..3201a1c 100644 --- a/publish.in +++ b/publish.in @@ -24,7 +24,7 @@ if [ -f "$SOURCETAR" ]; then if [ -f $TARBALL ]; then TARGETNAME=/tmp/bloatrunner echo unpack $TARBALL to $TARGETNAME - rm -f $TARGETNAME + rm -rf $TARGETNAME mkdir -p $TARGETNAME tar -xzvf $TARBALL -C $TARGETNAME