Compare commits

...

2 commits

Author SHA1 Message Date
f8647695a0 rethink asset loading 2024-05-25 14:10:23 +02:00
548cddc89d use relative paths for assets 2024-05-25 13:19:31 +02:00
8 changed files with 63 additions and 54 deletions

1
.gitignore vendored
View file

@ -14,3 +14,4 @@
/gnu/
/bloatrunner
/*.tar.gz
publish

View file

@ -9,6 +9,7 @@ AM_SILENT_RULES([yes])
AC_CONFIG_FILES([Makefile])
AC_CONFIG_FILES([pre-inst-env], [chmod +x pre-inst-env])
AC_CONFIG_FILES([bloatrunner], [chmod +x bloatrunner])
AC_CONFIG_FILES([publish], [chmod +x publish])
GUILE_PKG([3.0])
GUILE_PROGS

View file

@ -78,7 +78,7 @@
(%make-level width height tiles)))
(define (level-parse-file filename)
(level-parse (call-with-input-file (assets-file-name filename) get-string-all)))
(level-parse (call-with-input-file filename get-string-all)))
(define (level-tile-at-row-col level row col )

View file

@ -18,7 +18,7 @@
(define (food-index food cycle)
(let ((x (coord->cell (vec2-x (food-position food))))
(y (coord->cell (vec2-y (food-position food)))))
(pk "food remainder : " (remainder (+ (* x 37) (* 73 y)) cycle))))
(remainder (+ (* x 37) (* 73 y)) cycle)))
(define (render-food food)
(let ((index (food-index food (if (food-healthy? food) healthy-food-cycle bad-food-cycle)))

View file

@ -63,17 +63,13 @@
(if (equal? tile 'ladder)
;; add background behind ladder
(if (or (equal? (level-tile-at level (vec2+ position (vec2 16 0))) 'brick)
(equal? (level-tile-at level (vec2- position (vec2 -16 0))) 'brick)
)
(equal? (level-tile-at level (vec2- position (vec2 -16 0))) 'brick))
(sprite-batch-add! sprite-batch position
#:texture-region (texture-atlas-ref tile-atlas brick-index))
(sprite-batch-add! sprite-batch position
#:texture-region (texture-atlas-ref tile-atlas empty-index))))
(sprite-batch-add! sprite-batch position
#:texture-region texture-region)))
(iota (level-width level) 0)))
(iota (level-height level) 0)))
@ -84,10 +80,10 @@
(define (render-victory)
(draw-sprite (load-image (assets-file-name "assets/images/victory.jpg")) (vec2 0 0)))
(draw-sprite (assets-load-image "victory.jpg") (vec2 0 0)))
(define (render-defeat)
(draw-sprite (load-image (assets-file-name "assets/images/defeat.jpg")) (vec2 0 0)))
(draw-sprite (assets-load-image "defeat.jpg") (vec2 0 0)))
(test-begin "tile translation")

View file

@ -13,26 +13,36 @@
(define hero-texture #f)
(define hero-atlas #f)
(define prefix (or (getenv "ASSET_DIR") "." ))
(define (assets-file-name name)
(string-append prefix "/" name)
(define (assets-location)
(pk "Assets location: "
(if (current-filename)
(string-append (dirname (current-filename)) "/../../assets")
(or (getenv "ASSET_DIR") "." )))
)
(define (assets-file-name . names)
"Return the full path of a file in the assets directory. The file is
specified by a list of names, which are joined together. The
ASSET_DIR environment variable can be used to specify a prefix to the
asset directory."
(string-append (assets-location) "/" (string-join names "/")))
(define (read-level-map filename)
(call-with-input-file get-string-all))
(call-with-input-file filename get-string-all))
(define (assets-map-levels f)
(map f
(map (lambda (filename)(string-append prefix "/assets/levels/" filename))
(scandir (assets-file-name "assets/levels")
(map (lambda (filename)(assets-file-name "levels" filename))
(scandir (assets-file-name "levels")
(lambda (filename) (string-suffix? ".map" filename ))))))
(define (assets-load-image filename)
(load-image (assets-file-name "images" filename)))
(define (assets-load)
(set! tile-texture (load-image (assets-file-name "assets/images/simples_pimples.png")))
(set! tile-texture (assets-load-image "simples_pimples.png"))
(set! tile-atlas (split-texture tile-texture 16 16))
(set! hero-texture (load-image (assets-file-name "assets/images/lr_penguin2.png")))
(set! hero-texture (assets-load-image "lr_penguin2.png"))
(set! hero-atlas (split-texture hero-texture 32 32)))

36
publish.in Normal file
View file

@ -0,0 +1,36 @@
ITCH_CHANNEL=snamellit/Bloatrunner
if [[ ! -f Makefile ]]; then
make distclean
fi
./bootstrap.sh
./configure GUILE=$(which guile)
make -j16
make dist
SOURCETAR="@PACKAGE@-@VERSION@.tar.gz"
if [ -f "$SOURCETAR" ]; then
echo "Found source tarball $SOURCE"
BASENAME="@PACKAGE@-@VERSION@"
echo releasing $BASENAME
butler push $SOURCETAR $ITCH_CHANNEL:source
TARBALL=$(guix pack -R -Sbloatrunner=bin -L .guix/modules bloatrunner)
echo created $TARBALL
TARGETNAME=/tmp/$BASENAME-linux-x86_64.tar.gz
echo copy $TARBALL to $TARGETNAME
rm -f $TARGETNAME
cp $TARBALL $TARGETNAME
echo push $TARGETNAME
butler push $TARGETNAME $ITCH_CHANNEL:linux-x86_64
else
echo "No source tarball found"
exit 1
fi

View file

@ -1,35 +0,0 @@
ITCH_CHANNEL=snamellit/Bloatrunner
if [[ ! -f Makefile ]]; then
make distclean
fi
./bootstrap.sh
./configure GUILE=$(which guile)
make -j16
make dist
SOURCETAR=$(ls bloatrunner-*.tar.gz | head -n 1)
if [ -f "$SOURCETAR" ]; then
echo "Found source tarball $SOURCE"
BASENAME=$(basename $SOURCETAR .tar.gz)
echo releasing $BASENAME
butler push $SOURCETAR $ITCH_CHANNEL:source
TARBALL=$(guix pack -R -Sbloatrunner=bin -L .guix/modules bloatrunner)
echo created $TARBALL
TARGETNAME=/tmp/$BASENAME-linux-x86_64.tar.gz
echo copy $TARBALL to $TARGETNAME
rm -f $TARGETNAME
cp $TARBALL $TARGETNAME
echo push $TARGETNAME
butler push $TARGETNAME $ITCH_CHANNEL:linux-x86_64
else
echo "No source tarball found"
exit 1
fi