add support for assets and bundling
This commit is contained in:
parent
dd6b56bcb7
commit
b440da3600
6 changed files with 104 additions and 30 deletions
|
@ -32,15 +32,14 @@
|
||||||
#:select? vcs-file?))
|
#:select? vcs-file?))
|
||||||
(build-system gnu-build-system)
|
(build-system gnu-build-system)
|
||||||
(arguments
|
(arguments
|
||||||
'(#:make-flags '("GUILE_AUTO_COMPILE=0")
|
'(#:modules ((guix build gnu-build-system)
|
||||||
|
(guix build utils)
|
||||||
|
(ice-9 popen)
|
||||||
|
(ice-9 rdelim))
|
||||||
|
#:make-flags '("GUILE_AUTO_COMPILE=0")
|
||||||
|
|
||||||
#:phases
|
#:phases
|
||||||
(modify-phases %standard-phases
|
(modify-phases %standard-phases
|
||||||
;; (replace 'bootstrap
|
|
||||||
;; (lambda _
|
|
||||||
;; ;; The 'bootstrap' script lacks a shebang, leading to "Exec
|
|
||||||
;; ;; format error" with glibc 2.35.
|
|
||||||
;; (invoke "autoreconf" "-vfi")))
|
|
||||||
(add-after 'install-bin 'wrap-program
|
(add-after 'install-bin 'wrap-program
|
||||||
(lambda* (#:key inputs outputs #:allow-other-keys)
|
(lambda* (#:key inputs outputs #:allow-other-keys)
|
||||||
;; (use-modules (guix build guile-build-system))
|
;; (use-modules (guix build guile-build-system))
|
||||||
|
@ -49,7 +48,10 @@
|
||||||
(chickadee (assoc-ref inputs "guile-chickadee"))
|
(chickadee (assoc-ref inputs "guile-chickadee"))
|
||||||
(deps (list out chickadee))
|
(deps (list out chickadee))
|
||||||
(guile (assoc-ref inputs "guile"))
|
(guile (assoc-ref inputs "guile"))
|
||||||
(effective (target-guile-effective-version))
|
(effective (read-line
|
||||||
|
(open-pipe* OPEN_READ
|
||||||
|
(string-append guile "/bin/guile")
|
||||||
|
"-c" "(display (effective-version))")))
|
||||||
(mods (string-drop-right ;drop trailing colon
|
(mods (string-drop-right ;drop trailing colon
|
||||||
(string-join deps
|
(string-join deps
|
||||||
(string-append "/share/guile/site/"
|
(string-append "/share/guile/site/"
|
||||||
|
@ -57,14 +59,16 @@
|
||||||
'suffix)
|
'suffix)
|
||||||
1))
|
1))
|
||||||
(objs (string-drop-right
|
(objs (string-drop-right
|
||||||
(string-join deps
|
|
||||||
(string-append "/lib/guile/" effective
|
(string-append "/lib/guile/" effective
|
||||||
"/site-ccache:")
|
"/site-ccache:")
|
||||||
'suffix)
|
'suffix)
|
||||||
1)))
|
1)))
|
||||||
(wrap-program (string-append out "/bin/bloatrunner")
|
(wrap-program (string-append out "/bin/bloatrunner")
|
||||||
`("GUILE_LOAD_PATH" ":" prefix (,mods))
|
`("GUILE_LOAD_PATH" ":" prefix (,mods))
|
||||||
`("GUILE_LOAD_COMPILED_PATH" ":" prefix (,objs)))))))
|
`("GUILE_LOAD_COMPILED_PATH" ":" prefix (,objs))
|
||||||
|
`("ASSET_DIR" ":" prefix (,(string-append out "/share/bloatrunner")))
|
||||||
|
)))))
|
||||||
))
|
))
|
||||||
(native-inputs
|
(native-inputs
|
||||||
(list autoconf automake pkg-config))
|
(list autoconf automake pkg-config))
|
||||||
|
|
58
README.org
58
README.org
|
@ -45,7 +45,10 @@ So now, go out, collect the keys and maintain a healthy diet!
|
||||||
- [X] create hero entity
|
- [X] create hero entity
|
||||||
- [X] implement hero movement
|
- [X] implement hero movement
|
||||||
- [X] create other entity
|
- [X] create other entity
|
||||||
- [ ] bundle game for distribution
|
- [-] bundle game for distribution
|
||||||
|
- [X] add assets to the package
|
||||||
|
- [X] wrap the script to find the libraries
|
||||||
|
- [ ] ensure the assets can be found by the render packages
|
||||||
- [ ] upload to itch.io
|
- [ ] upload to itch.io
|
||||||
- [ ] automate upload to itch.io
|
- [ ] automate upload to itch.io
|
||||||
- [ ] create other's AI
|
- [ ] create other's AI
|
||||||
|
@ -170,3 +173,56 @@ guix pack -L .guix/modules bloatrunner
|
||||||
#+END_SRC
|
#+END_SRC
|
||||||
|
|
||||||
Generates a 750Mb installed folder structure with everything in it, theoretically
|
Generates a 750Mb installed folder structure with everything in it, theoretically
|
||||||
|
|
||||||
|
To add the startup script :
|
||||||
|
|
||||||
|
#+BEGIN_SRC
|
||||||
|
|
||||||
|
#+END_SRC
|
||||||
|
|
||||||
|
This startup script needs to be wrapped during installation to find
|
||||||
|
the libraries. This requires calling the `wrap-program` utility with
|
||||||
|
the environment variables set according to the installed environment.
|
||||||
|
|
||||||
|
#+BEGIN_SRC scheme
|
||||||
|
(arguments
|
||||||
|
'(#:modules ((guix build gnu-build-system)
|
||||||
|
(guix build utils)
|
||||||
|
(ice-9 popen)
|
||||||
|
(ice-9 rdelim))
|
||||||
|
#:make-flags '("GUILE_AUTO_COMPILE=0")
|
||||||
|
|
||||||
|
#:phases
|
||||||
|
(modify-phases %standard-phases
|
||||||
|
(add-after 'install-bin 'wrap-program
|
||||||
|
(lambda* (#:key inputs outputs #:allow-other-keys)
|
||||||
|
;; (use-modules (guix build guile-build-system))
|
||||||
|
;; Wrap the 'gitile' command to refer to the right modules.
|
||||||
|
(let* ((out (assoc-ref outputs "out"))
|
||||||
|
(chickadee (assoc-ref inputs "guile-chickadee"))
|
||||||
|
(deps (list out chickadee))
|
||||||
|
(guile (assoc-ref inputs "guile"))
|
||||||
|
(effective (read-line
|
||||||
|
(open-pipe* OPEN_READ
|
||||||
|
(string-append guile "/bin/guile")
|
||||||
|
"-c" "(display (effective-version))")))
|
||||||
|
(mods (string-drop-right ;drop trailing colon
|
||||||
|
(string-join deps
|
||||||
|
(string-append "/share/guile/site/"
|
||||||
|
effective ":")
|
||||||
|
'suffix)
|
||||||
|
1))
|
||||||
|
(objs (string-drop-right
|
||||||
|
(string-join deps
|
||||||
|
(string-append "/lib/guile/" effective
|
||||||
|
"/site-ccache:")
|
||||||
|
'suffix)
|
||||||
|
1)))
|
||||||
|
(wrap-program (string-append out "/bin/bloatrunner")
|
||||||
|
`("GUILE_LOAD_PATH" ":" prefix (,mods))
|
||||||
|
`("GUILE_LOAD_COMPILED_PATH" ":" prefix (,objs)))))))
|
||||||
|
))
|
||||||
|
|
||||||
|
#+END_SRC
|
||||||
|
|
||||||
|
most of this is dynamically construct the content of the paths.
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
(define-module (game render hero)
|
(define-module (game render hero)
|
||||||
#:use-module (game model hero)
|
#:use-module (game model hero)
|
||||||
|
#:use-module (game util assets)
|
||||||
#:use-module (chickadee)
|
#:use-module (chickadee)
|
||||||
#:use-module (chickadee math vector)
|
#:use-module (chickadee math vector)
|
||||||
#:use-module (chickadee graphics sprite)
|
#:use-module (chickadee graphics sprite)
|
||||||
|
@ -13,7 +14,7 @@
|
||||||
(define hero-atlas #f)
|
(define hero-atlas #f)
|
||||||
|
|
||||||
(define (render-hero-load)
|
(define (render-hero-load)
|
||||||
(set! hero-texture (load-image "assets/images/lr_penguin2.png"))
|
(set! hero-texture (load-image (asset-file-name "assets/images/lr_penguin2.png")))
|
||||||
(set! hero-atlas (split-texture hero-texture 32 32)))
|
(set! hero-atlas (split-texture hero-texture 32 32)))
|
||||||
|
|
||||||
;; start index of the walk animation
|
;; start index of the walk animation
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
(define-module (game render level)
|
(define-module (game render level)
|
||||||
#:use-module (game model level)
|
#:use-module (game model level)
|
||||||
|
#:use-module (game util assets)
|
||||||
#:use-module (srfi srfi-64)
|
#:use-module (srfi srfi-64)
|
||||||
#:use-module (chickadee graphics color)
|
#:use-module (chickadee graphics color)
|
||||||
#:use-module (chickadee graphics sprite)
|
#:use-module (chickadee graphics sprite)
|
||||||
|
@ -19,7 +20,7 @@
|
||||||
|
|
||||||
;; load the tile texture and split it into a tile atlas
|
;; load the tile texture and split it into a tile atlas
|
||||||
(define (render-level-load)
|
(define (render-level-load)
|
||||||
(set! tile-texture (load-image "assets/images/simples_pimples.png"
|
(set! tile-texture (load-image (asset-file-name "assets/images/simples_pimples.png")
|
||||||
#:transparent-color black))
|
#:transparent-color black))
|
||||||
(set! tile-atlas (split-texture tile-texture 16 16))
|
(set! tile-atlas (split-texture tile-texture 16 16))
|
||||||
(set! sprite-batch (make-sprite-batch tile-texture #:capacity 1200))
|
(set! sprite-batch (make-sprite-batch tile-texture #:capacity 1200))
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
(define-module (game render other)
|
(define-module (game render other)
|
||||||
#:use-module (game model other)
|
#:use-module (game model other)
|
||||||
|
#:use-module (game util assets)
|
||||||
#:use-module (chickadee)
|
#:use-module (chickadee)
|
||||||
#:use-module (chickadee math vector)
|
#:use-module (chickadee math vector)
|
||||||
#:use-module (chickadee graphics sprite)
|
#:use-module (chickadee graphics sprite)
|
||||||
|
@ -12,7 +13,7 @@
|
||||||
(define other-atlas #f)
|
(define other-atlas #f)
|
||||||
|
|
||||||
(define (render-other-load)
|
(define (render-other-load)
|
||||||
(set! other-atlas (split-texture (load-image "assets/images/simples_pimples.png") 16 16)))
|
(set! other-atlas (split-texture (load-image (asset-file-name "assets/images/simples_pimples.png")) 16 16)))
|
||||||
|
|
||||||
;; start index of the walk animation
|
;; start index of the walk animation
|
||||||
(define other-walking-offset 3926)
|
(define other-walking-offset 3926)
|
||||||
|
|
11
game/util/assets.scm
Normal file
11
game/util/assets.scm
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
(define-module (game util assets)
|
||||||
|
#:export (asset-file-name)
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
(define prefix (or (getenv "ASSET_DIR") "." ))
|
||||||
|
|
||||||
|
|
||||||
|
(define (asset-file-name name)
|
||||||
|
(string-append prefix "/" name)
|
||||||
|
)
|
Loading…
Reference in a new issue