Add top-level layer, renders above player
This commit is contained in:
parent
346d9d3a9d
commit
b4cde1ea16
|
@ -168,18 +168,19 @@ Returns parameters to be used in the next invocation of OVERWORLD-STATE."
|
|||
"Draw the overworld map to the given matrix.
|
||||
A core part of OVERWORLD-STATE."
|
||||
(let* ((chunk (world-coords-chunk (getf-entity-data map 'player :coords))))
|
||||
(matrix-write-map-chunk matrix map chunk)
|
||||
(matrix-write-entities matrix map chunk)))
|
||||
(matrix-write-tiles matrix (gethash :tiles map) chunk)
|
||||
(matrix-write-entities matrix map chunk)
|
||||
(matrix-write-tiles matrix (gethash :top-tiles map) chunk)))
|
||||
|
||||
|
||||
(defun matrix-write-map-chunk (matrix map chunk
|
||||
&key (chunk-width 72) (chunk-height 20))
|
||||
(defun matrix-write-tiles (matrix tiles chunk
|
||||
&key (chunk-width 72) (chunk-height 20))
|
||||
"Draw a map’s specific chunk (by its ID) to the matrix."
|
||||
(mapcar (lambda (cell)
|
||||
(if (or (not (getf cell :lang))
|
||||
(eq (getf cell :lang) (…:system-language)))
|
||||
(matrix-write-cell matrix cell)))
|
||||
(cdr (assoc chunk (gethash :tiles map)))))
|
||||
(cdr (assoc chunk tiles))))
|
||||
|
||||
|
||||
(defun matrix-write-cell (matrix cell)
|
||||
|
@ -194,7 +195,7 @@ alist containing a character (:CHAR) and :X & :Y coordinates."
|
|||
|
||||
|
||||
;;; ———————————————————————————————————
|
||||
;;; Overworld-drawing: Entity-rendering
|
||||
;;; Overworld-drawing: Person-rendering
|
||||
;;; ———————————————————————————————————
|
||||
(defun matrix-write-entities (matrix map chunk)
|
||||
"Draw all entities from an alist of entities to the matrix."
|
||||
|
|
|
@ -148,6 +148,7 @@ with 15 characters-per-line."
|
|||
:TILES, an alist of visible tiles (keyed by chunk).
|
||||
:ENTITIES, a list of entity plists."
|
||||
(let ((tile-chunks '())
|
||||
(top-tiles '())
|
||||
(bump-map '())
|
||||
(entities '())
|
||||
(hash (make-hash-table)))
|
||||
|
@ -157,11 +158,14 @@ with 15 characters-per-line."
|
|||
;; Add to the bump-map if the layer is colliding
|
||||
(when (gethash "colliding" (cl-tiled:properties layer))
|
||||
(setf bump-map (tile-layer-chunks layer bump-map)))
|
||||
(setf tile-chunks (tile-layer-chunks layer tile-chunks)))
|
||||
(if (gethash "top-layer" (cl-tiled:properties layer))
|
||||
(setf top-tiles (tile-layer-chunks layer top-tiles))
|
||||
(setf tile-chunks (tile-layer-chunks layer tile-chunks))))
|
||||
(cl-tiled.data-types:object-layer
|
||||
(setf entities (object-layer-entities layer entities)))))
|
||||
(cl-tiled:map-layers (cl-tiled:load-map map-file)))
|
||||
(setf (gethash :tiles hash) tile-chunks)
|
||||
(setf (gethash :top-tiles hash) top-tiles)
|
||||
(setf (gethash :bump-map hash) bump-map)
|
||||
(setf (gethash :entities hash) entities)
|
||||
hash))
|
||||
|
|
Ŝarĝante…
Reference in New Issue