Persistent data between maps! How exciting!
I spent a good chunk of time trying to get rid of the maps’ global variables, instead packing each map into a :map variable in a “game” hash-table… but, wow, that took a while. And also made things a bit more complicated. And also… we could just do this. From this commit. So much easier! @-@
This commit is contained in:
parent
766f2dedee
commit
738239f50a
|
@ -141,11 +141,11 @@
|
||||||
|
|
||||||
|
|
||||||
(defun casino-entrance-trigger (&optional map)
|
(defun casino-entrance-trigger (&optional map)
|
||||||
(list :map *casino-map*))
|
(list :map (🌍:merge-maps map *casino-map*)))
|
||||||
|
|
||||||
|
|
||||||
(defun casino-exit-trigger (&optional map)
|
(defun casino-exit-trigger (&optional map)
|
||||||
(list :map *outdoors-map*))
|
(list :map (🌍:merge-maps map *outdoors-map*)))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -22,6 +22,7 @@
|
||||||
(:use :cl
|
(:use :cl
|
||||||
:flora-search-aurora.overworld.tiled :flora-search-aurora.overworld.util)
|
:flora-search-aurora.overworld.tiled :flora-search-aurora.overworld.util)
|
||||||
(:export #:overworld-state #:make-overworld-state #:overworld-state-draw
|
(:export #:overworld-state #:make-overworld-state #:overworld-state-draw
|
||||||
|
#:merge-maps
|
||||||
#:world-coords->screen-coords
|
#:world-coords->screen-coords
|
||||||
#:getf-entity #:getf-entity-data
|
#:getf-entity #:getf-entity-data
|
||||||
#:move-entity-to #:move-entity
|
#:move-entity-to #:move-entity
|
||||||
|
@ -301,3 +302,15 @@ A state-function for use with STATE-LOOP."
|
||||||
(apply #'🌍:overworld-state
|
(apply #'🌍:overworld-state
|
||||||
(append (list matrix :map-path map-path)
|
(append (list matrix :map-path map-path)
|
||||||
args))))
|
args))))
|
||||||
|
|
||||||
|
|
||||||
|
(defun merge-maps (map-a map-b)
|
||||||
|
"Copy data that should be persistent between maps from map-a to map-b."
|
||||||
|
(setf (gethash :acts map-b) (gethash :acts map-a))
|
||||||
|
(setf (gethash :knows map-b) (gethash :knows map-a))
|
||||||
|
(mapcar
|
||||||
|
(lambda (player-key)
|
||||||
|
(setf (getf-entity-data map-b 'player player-key)
|
||||||
|
(getf-entity-data map-a 'player player-key)))
|
||||||
|
'(:face :normal-face :talking-face))
|
||||||
|
map-b)
|
||||||
|
|
Ŝarĝante…
Reference in New Issue