Compare commits

...

2 commits

Author SHA1 Message Date
nephryte
8e49207c72 Merge branch 'main' of https://git.solarpunk.moe/TakeV/lisp-game-jam 2024-05-25 22:04:51 -04:00
nephryte
204875e7f3 Initialize tile map stuff in game manager 2024-05-25 22:03:12 -04:00
5 changed files with 33 additions and 9 deletions

View file

@ -32,14 +32,14 @@
(height tile-height))
(define-record-type <tileset>
(make-tileset tile-width tile-height tiles)
(make-tileset tiles tile-width tile-height)
tileset?
(tile-width ts-tile-width)
(tile-height ts-tile-height)
(tiles ts-tiles))
(define-record-type <tilemap-layer>
(make-tile-layer data x y width height)
(make-tilemap-layer data x y width height)
tilemap-layer?
(data tl-data)
(x tl-x)

View file

@ -24,7 +24,9 @@
(for-each (lambda (layer)
(let ((data (tl-data layer))
(x-offset (tl-x layer))
(y-offset (tl-y layer)))
(y-offset (tl-y layer))
(tl-width (tl-width layer))
(tl-height (tl-height layer)))
(for-each (lambda (index)
(let* ((tile (vector-ref ts-tiles index))
(img (tile-image tile))

View file

@ -4,14 +4,31 @@
#:use-module (ces system html-canvas-renderer)
#:use-module (dom image)
#:use-module (media)
#:use-module (ces component tilemap)
#:use-module (game level-manager)
#:use-module (logging)
#:export (init-game-entities
init-game-systems))
(define (init-game-entities)
"Returns a list of initial game entities. "
(let ((room-background (get-image (get-media-library) 'room-background))
(room-tilemap '()))
(write-log! "Init game entities")
(let* ((room-background (get-image (get-media-library) 'room-background))
(ts-vec (write-log! (vector
(make-tile 'tile-blank 16 16)
(make-tile 'tile-floor 16 16)
(make-tile 'tile-wall 16 16)
(make-tile 'tile-door 16 16))))
(tl-vec (write-log!
#(2 2 2 2 3 2 2 2
1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1)))
(room-tilemap
(make-tilemap
(make-tileset ts-vec 16 16)
(list
(make-tilemap-layer tl-vec 0 0 8 4)))))
(list (create-player!)
(create-room! room-tilemap))))

View file

@ -9,6 +9,7 @@
#:use-module (ces entity-manager)
#:use-module (game-core)
#:use-module (dom image)
#:use-module (logging)
#:export (add-game-object-components
game-object?
create-game-object!))
@ -33,7 +34,8 @@
(has-components? entity 'position 'hitbox 'sprite))
(define (create-game-object! x y width height sprite)
(let* ((e-manager (get-entity-manager))
(entity (create-entity! e-manager)))
(write-log! "create-game-object!")
(let* ((e-manager (write-log! (get-entity-manager)))
(entity (write-log! (create-entity! e-manager))))
(reset-entity! e-manager
(add-game-object-components entity x y width height sprite))))

View file

@ -11,6 +11,7 @@
#:use-module (game game-objects)
#:use-module (game-core)
#:use-module (media)
#:use-module (logging)
#:export (create-player!
create-room!))
@ -20,8 +21,10 @@
(has-components? entity 'keyboard-input)))
(define (create-player!)
(let* ((player-sprite (get-image (get-media-library) 'player))
(initial-entity (create-game-object! 0 0 16 16 player-sprite)))
(let* (
(player-sprite (write-log! (get-image (get-media-library) 'player)))
(initial-entity (write-log! (create-game-object! 0 0 16 16 player-sprite)))
)
(set-component initial-entity 'keyboard-input
(create-inputs))))