Compare commits
2 commits
86af891b0c
...
8e49207c72
Author | SHA1 | Date | |
---|---|---|---|
|
8e49207c72 | ||
|
204875e7f3 |
5 changed files with 33 additions and 9 deletions
|
@ -32,14 +32,14 @@
|
||||||
(height tile-height))
|
(height tile-height))
|
||||||
|
|
||||||
(define-record-type <tileset>
|
(define-record-type <tileset>
|
||||||
(make-tileset tile-width tile-height tiles)
|
(make-tileset tiles tile-width tile-height)
|
||||||
tileset?
|
tileset?
|
||||||
(tile-width ts-tile-width)
|
(tile-width ts-tile-width)
|
||||||
(tile-height ts-tile-height)
|
(tile-height ts-tile-height)
|
||||||
(tiles ts-tiles))
|
(tiles ts-tiles))
|
||||||
|
|
||||||
(define-record-type <tilemap-layer>
|
(define-record-type <tilemap-layer>
|
||||||
(make-tile-layer data x y width height)
|
(make-tilemap-layer data x y width height)
|
||||||
tilemap-layer?
|
tilemap-layer?
|
||||||
(data tl-data)
|
(data tl-data)
|
||||||
(x tl-x)
|
(x tl-x)
|
||||||
|
|
|
@ -24,7 +24,9 @@
|
||||||
(for-each (lambda (layer)
|
(for-each (lambda (layer)
|
||||||
(let ((data (tl-data layer))
|
(let ((data (tl-data layer))
|
||||||
(x-offset (tl-x 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)
|
(for-each (lambda (index)
|
||||||
(let* ((tile (vector-ref ts-tiles index))
|
(let* ((tile (vector-ref ts-tiles index))
|
||||||
(img (tile-image tile))
|
(img (tile-image tile))
|
||||||
|
|
|
@ -4,14 +4,31 @@
|
||||||
#:use-module (ces system html-canvas-renderer)
|
#:use-module (ces system html-canvas-renderer)
|
||||||
#:use-module (dom image)
|
#:use-module (dom image)
|
||||||
#:use-module (media)
|
#:use-module (media)
|
||||||
|
#:use-module (ces component tilemap)
|
||||||
#:use-module (game level-manager)
|
#:use-module (game level-manager)
|
||||||
|
#:use-module (logging)
|
||||||
#:export (init-game-entities
|
#:export (init-game-entities
|
||||||
init-game-systems))
|
init-game-systems))
|
||||||
|
|
||||||
(define (init-game-entities)
|
(define (init-game-entities)
|
||||||
"Returns a list of initial game entities. "
|
"Returns a list of initial game entities. "
|
||||||
(let ((room-background (get-image (get-media-library) 'room-background))
|
(write-log! "Init game entities")
|
||||||
(room-tilemap '()))
|
(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!)
|
(list (create-player!)
|
||||||
(create-room! room-tilemap))))
|
(create-room! room-tilemap))))
|
||||||
|
|
||||||
|
|
|
@ -9,6 +9,7 @@
|
||||||
#:use-module (ces entity-manager)
|
#:use-module (ces entity-manager)
|
||||||
#:use-module (game-core)
|
#:use-module (game-core)
|
||||||
#:use-module (dom image)
|
#:use-module (dom image)
|
||||||
|
#:use-module (logging)
|
||||||
#:export (add-game-object-components
|
#:export (add-game-object-components
|
||||||
game-object?
|
game-object?
|
||||||
create-game-object!))
|
create-game-object!))
|
||||||
|
@ -33,7 +34,8 @@
|
||||||
(has-components? entity 'position 'hitbox 'sprite))
|
(has-components? entity 'position 'hitbox 'sprite))
|
||||||
|
|
||||||
(define (create-game-object! x y width height sprite)
|
(define (create-game-object! x y width height sprite)
|
||||||
(let* ((e-manager (get-entity-manager))
|
(write-log! "create-game-object!")
|
||||||
(entity (create-entity! e-manager)))
|
(let* ((e-manager (write-log! (get-entity-manager)))
|
||||||
|
(entity (write-log! (create-entity! e-manager))))
|
||||||
(reset-entity! e-manager
|
(reset-entity! e-manager
|
||||||
(add-game-object-components entity x y width height sprite))))
|
(add-game-object-components entity x y width height sprite))))
|
||||||
|
|
|
@ -11,6 +11,7 @@
|
||||||
#:use-module (game game-objects)
|
#:use-module (game game-objects)
|
||||||
#:use-module (game-core)
|
#:use-module (game-core)
|
||||||
#:use-module (media)
|
#:use-module (media)
|
||||||
|
#:use-module (logging)
|
||||||
#:export (create-player!
|
#:export (create-player!
|
||||||
create-room!))
|
create-room!))
|
||||||
|
|
||||||
|
@ -20,8 +21,10 @@
|
||||||
(has-components? entity 'keyboard-input)))
|
(has-components? entity 'keyboard-input)))
|
||||||
|
|
||||||
(define (create-player!)
|
(define (create-player!)
|
||||||
(let* ((player-sprite (get-image (get-media-library) 'player))
|
(let* (
|
||||||
(initial-entity (create-game-object! 0 0 16 16 player-sprite)))
|
(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
|
(set-component initial-entity 'keyboard-input
|
||||||
(create-inputs))))
|
(create-inputs))))
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue