Compress maps by _a bunch_!

Look at these gains:
  672K    old-outdoors.tmx.lisp
  264K    new-outdoors.tmx.lisp
This commit is contained in:
Jaidyn Ann 2023-07-07 10:33:32 -05:00
parent ad3980a538
commit 63e31ef4f8
3 changed files with 16 additions and 9 deletions

View File

@ -5,9 +5,13 @@ USE_SWANK ?= no
fonts: fonts:
$(LISP) \ $(LISP) \
--load "res/fonts/flf→lisp.lisp" --load "res/fonts/flf→lisp.lisp"
maps: maps:
$(LISP) \ $(LISP) \
--load "res/maps/tmx→lisp.lisp" --load "res/maps/tmx→lisp.lisp"
sed -i 's%:LANG NIL%%g' res/maps/*.tmx.lisp
sed -i 's%^[ ]*%%' res/maps/*.tmx.lisp
sed -i 's%) (%)(%g' res/maps/*.tmx.lisp
build: maps fonts build: maps fonts
$(LISP) \ $(LISP) \

View File

@ -121,7 +121,8 @@ replays of the game."
(let ((chunk (world-coords-chunk coords))) (let ((chunk (world-coords-chunk coords)))
(member 't (cdr (assoc chunk map-chunks)) (member 't (cdr (assoc chunk map-chunks))
:test (lambda (ignored cell) :test (lambda (ignored cell)
(:plist= (getf cell :coords) coords))))) (:plist= (list :x (getf cell :x) :y (getf cell :y))
coords)))))
(defun walkable-tile-p (map x y) (defun walkable-tile-p (map x y)
@ -235,6 +236,8 @@ Returns parameters to be used in the next invocation of OVERWORLD-STATE."
(defun move-player (map &key (Δx 0) (Δy 0)) (defun move-player (map &key (Δx 0) (Δy 0))
"Moves the play by the given changes in x & y.
Very kindly removes a list of parameters to be returned by the overworld state-function."
(move-entity map ':player :Δx Δx :Δy Δy) (move-entity map ':player :Δx Δx :Δy Δy)
(let* ((coords (getf-entity-data map ':player :coords)) (let* ((coords (getf-entity-data map ':player :coords))
(trigger (trigger-at-coords map (list :x (getf coords :x) :y (getf coords :y))))) (trigger (trigger-at-coords map (list :x (getf coords :x) :y (getf coords :y)))))
@ -305,13 +308,13 @@ A core part of OVERWORLD-STATE."
(defun matrix-write-cell (matrix cell) (defun matrix-write-cell (matrix cell)
"Set a matrice's (2d array's) element corresponding to a cell; that is, an "Set a matrice's (2d array's) element corresponding to a cell; that is, a
alist containing a character (:CHAR) and :X & :Y coordinates." plist containing a character (:CHAR) and :X & :Y coordinates."
(let ((coords (world-coords->screen-coords (getf cell :coords)))) (let ((coords (world-coords->screen-coords (list :x (getf cell :x) :y (getf cell :y)))))
(setf (aref matrix (setf (aref matrix
(getf coords :y) (getf coords :y)
(getf coords :x)) (getf coords :x))
(getf cell :char)))) (getf cell :@))))

View File

@ -123,9 +123,9 @@ a :FUNCTION to be triggered when its stepped upon."
;;; ——————————————————————————————————— ;;; ———————————————————————————————————
(defun tiled-cell->cell (tiled-cell &key (language nil)) (defun tiled-cell->cell (tiled-cell &key (language nil))
"Convert a Tiled cell into a cell plist." "Convert a Tiled cell into a cell plist."
(list :coords (list :x (cl-tiled:cell-column tiled-cell) (list :x (cl-tiled:cell-column tiled-cell)
:y (cl-tiled:cell-row tiled-cell)) :y (cl-tiled:cell-row tiled-cell)
:char (tile-character (cl-tiled:cell-tile tiled-cell)) :@ (tile-character (cl-tiled:cell-tile tiled-cell))
:lang language)) :lang language))
@ -145,7 +145,7 @@ alist of Tiled cell “chunks”."
(collect-items-into-groups (collect-items-into-groups
(tiled-layer-cells layer) (tiled-layer-cells layer)
(lambda (cell) (lambda (cell)
(world-coords-chunk (getf cell :coords))) (world-coords-chunk (list :x (getf cell :x) :y (getf cell :y))))
:groups chunks)) :groups chunks))