From 63e31ef4f832f8ead1f5396f4415c3a30de0ff3a Mon Sep 17 00:00:00 2001 From: Jaidyn Ann <10477760+JadedCtrl@users.noreply.github.com> Date: Fri, 7 Jul 2023 10:33:32 -0500 Subject: [PATCH] Compress maps by _a bunch_! Look at these gains: 672K old-outdoors.tmx.lisp 264K new-outdoors.tmx.lisp --- Makefile | 4 ++++ overworld.lisp | 13 ++++++++----- overworld.tiled.lisp | 8 ++++---- 3 files changed, 16 insertions(+), 9 deletions(-) diff --git a/Makefile b/Makefile index 5af4785..c393825 100644 --- a/Makefile +++ b/Makefile @@ -5,9 +5,13 @@ USE_SWANK ?= no fonts: $(LISP) \ --load "res/fonts/flf→lisp.lisp" + maps: $(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 $(LISP) \ diff --git a/overworld.lisp b/overworld.lisp index 9888ab7..bb4f168 100644 --- a/overworld.lisp +++ b/overworld.lisp @@ -121,7 +121,8 @@ replays of the game." (let ((chunk (world-coords-chunk coords))) (member 't (cdr (assoc chunk map-chunks)) :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) @@ -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)) + "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) (let* ((coords (getf-entity-data map '✿:player :coords)) (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) - "Set a matrice's (2d array's) element corresponding to a “cell”; that is, an -alist containing a character (:CHAR) and :X & :Y coordinates." - (let ((coords (world-coords->screen-coords (getf cell :coords)))) + "Set a matrice's (2d array's) element corresponding to a “cell”; that is, a +plist containing a character (:CHAR) and :X & :Y coordinates." + (let ((coords (world-coords->screen-coords (list :x (getf cell :x) :y (getf cell :y))))) (setf (aref matrix (getf coords :y) (getf coords :x)) - (getf cell :char)))) + (getf cell :@)))) diff --git a/overworld.tiled.lisp b/overworld.tiled.lisp index 51ceb1b..d3cddc1 100644 --- a/overworld.tiled.lisp +++ b/overworld.tiled.lisp @@ -123,9 +123,9 @@ a :FUNCTION to be triggered when it’s stepped upon." ;;; ——————————————————————————————————— (defun tiled-cell->cell (tiled-cell &key (language nil)) "Convert a Tiled cell into a cell plist." - (list :coords (list :x (cl-tiled:cell-column tiled-cell) - :y (cl-tiled:cell-row tiled-cell)) - :char (tile-character (cl-tiled:cell-tile tiled-cell)) + (list :x (cl-tiled:cell-column tiled-cell) + :y (cl-tiled:cell-row tiled-cell) + :@ (tile-character (cl-tiled:cell-tile tiled-cell)) :lang language)) @@ -145,7 +145,7 @@ alist of Tiled cell “chunks”." (collect-items-into-groups (tiled-layer-cells layer) (lambda (cell) - (world-coords-chunk (getf cell :coords))) + (world-coords-chunk (list :x (getf cell :x) :y (getf cell :y)))) :groups chunks))