Use state return-values for overworld loop
This commit is contained in:
parent
8cbd029d6d
commit
32c95c3725
|
@ -96,8 +96,11 @@ or something ¯\_(ツ)_/¯"
|
||||||
(defun make-main-overworld-state ()
|
(defun make-main-overworld-state ()
|
||||||
"Return a state-function for the game’s overworld (the majority of the game), for use with
|
"Return a state-function for the game’s overworld (the majority of the game), for use with
|
||||||
#'state-loop."
|
#'state-loop."
|
||||||
(lambda (matrix)
|
(lambda (matrix &rest args)
|
||||||
(overworld-state matrix "/home/jaidyn/.local/src/games/flora search aurora/res/map.tmx")))
|
(apply #'overworld-state
|
||||||
|
(append (list matrix)
|
||||||
|
'(:map-path #p"/home/jaidyn/.local/src/games/flora search aurora/res/map.tmx")
|
||||||
|
args))))
|
||||||
|
|
||||||
|
|
||||||
(defun main ()
|
(defun main ()
|
||||||
|
|
|
@ -30,27 +30,25 @@
|
||||||
;;; ———————————————————————————————————
|
;;; ———————————————————————————————————
|
||||||
;;; Overworld loop
|
;;; Overworld loop
|
||||||
;;; ———————————————————————————————————
|
;;; ———————————————————————————————————
|
||||||
(defun overworld-state (matrix map)
|
(defun overworld-state (matrix &key (map-path nil) (map nil) (entity-data nil))
|
||||||
"Render the given map to the matrix and take user-input — for one frame.
|
"Render the given map to the matrix and take user-input — for one frame.
|
||||||
A state-function for use with #'state-loop."
|
A state-function for use with #'state-loop."
|
||||||
(let ((map (if (or (stringp map) (pathnamep map))
|
|
||||||
(cl-tiled:load-map map)
|
|
||||||
map)))
|
|
||||||
(sleep .02)
|
(sleep .02)
|
||||||
(overworld-state-draw matrix map)
|
(let ((map (if (not map) (cl-tiled:load-map map-path) map)))
|
||||||
(overworld-state-update map)))
|
(overworld-state-draw matrix map entity-data)
|
||||||
|
(overworld-state-update map entity-data)))
|
||||||
|
|
||||||
|
|
||||||
(defun overworld-state-draw (matrix map)
|
(defun overworld-state-draw (matrix map entity-data)
|
||||||
"Draw the overworld map to the given matrix.
|
"Draw the overworld map to the given matrix.
|
||||||
A core part of #'overworld-state."
|
A core part of #'overworld-state."
|
||||||
(matrix-write-tiled-map matrix map))
|
(matrix-write-tiled-map matrix map))
|
||||||
|
|
||||||
|
|
||||||
(defun overworld-state-update (map)
|
(defun overworld-state-update (map entity-data)
|
||||||
"Do nothing, lol.
|
"Do nothing, lol. Core part of #'overworld-state.
|
||||||
Core part of #'overworld-state."
|
Returns parameters to be used in the next invocation of #'overworld-state."
|
||||||
't)
|
(list :map map :entity-data entity-data))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
Ŝarĝante…
Reference in New Issue