Slightly tweak the engine thingy

This commit is contained in:
Jaidyn Ann 2023-07-11 22:14:02 -05:00
parent 1ab64221cd
commit 63515434d0
5 changed files with 47 additions and 50 deletions

View File

@ -213,19 +213,20 @@ Returns the state for use with STATE-LOOP, pay attention!"
((or (and did-press-enter-p did-finish-printing-p did-finish-moving-p)
(and (not text) did-finish-moving-p))
(if (cdr dialogue-list)
(list :dialogue (cdr dialogue-list) :map map)
(list :parameters (list :dialogue (cdr dialogue-list) :map map))
(progn
(:hide-cursor)
(values (or (getf dialogue :return) nil)
(or (getf dialogue :return-2)
(list :drop 1
:function (getf dialogue :function)
:parameters (or (getf dialogue :parameters)
(list :map map))))))
;; Allow interupting text-printing to end it!
((and did-press-enter-p (not did-finish-printing-p))
(setf (getf (car dialogue-list) :progress) (length text))
(list :dialogue dialogue-list :map map))
(list :parameters (list :dialogue dialogue-list :map map)))
;; If no input, keep steady!
('t
(list :dialogue dialogue-list :map map)))))
(list :parameters (list :dialogue dialogue-list :map map))))))
@ -394,9 +395,10 @@ A state-function for use with STATE-LOOP."
(defun make-dialogue-state (map dialogue-list)
"Return a state-function for a section of dialogue, for use with STATE-LOOP."
(list :function
(lambda (matrix &key (map map) (dialogue dialogue-list))
(🌍:overworld-state-draw matrix map)
(dialogue-state matrix :map map :dialogue dialogue)))
(dialogue-state matrix :map map :dialogue dialogue))))
;; Split a banana in two, bisection-fruit,

View File

@ -31,31 +31,31 @@ to the terminal.
What the state-function returns is pretty important, having different repercussions:
* NIL The function is removed from STATES, and so the next function in STATES will start
getting executed instead.
* NIL; List — The function is popped off STATES and the list is used as the new parameters for
the next function in STATES.
* Function The function is pushed to the front of STATES, and so is executed instead of the
current function.
* List The current function (front of STATES) continues to be executed with the given
list as a parameters list.
* T The function will continue to be run with the same parameters.
* (:FUNCTION FUNCTION :PARAMETERS LIST :DROP NUMBER)
Make note to add a delay w SLEEP to your state functions, or well, yknow. Your computer will
overheat, or something ¯\_()_/¯"
(when states
(multiple-value-bind (state-result new-state-params)
(apply (car states) (cons matrix state-params)) ;; Run the latest-added update/draw loop
(let ((state-result
(apply (car states) (cons matrix state-params)))) ;; Run the last-added state-loop.
(:print-screen-matrix (:matrix-delta last-matrix matrix)) ;; Print its results.
(format *error-output* "~S~%" state-result)
(force-output)
(state-loop
(cond ((functionp state-result)
(cons state-result states))
(cond ((listp state-result)
(nconc (if (getf state-result :function)
(list (getf state-result :function)))
(nthcdr (or (getf state-result :drop) 0) states)))
((not state-result)
(cdr states))
('t states))
:last-matrix matrix
:state-params
(cond ((not state-result)
new-state-params)
((listp state-result)
state-result))))))
(cond ((listp state-result)
(getf state-result :parameters))
((not state-result)
nil)
('t state-params))
:last-matrix matrix))))
(defun main (states)

View File

@ -129,7 +129,8 @@ Useful for making barriers the player character refuses to traverse."
(defun entrance-trigger (map trigger-plist)
"A trigger that can be used to move the user from one MAP to another, via the
:MAP property in a triggers Tiled entity."
(list :map (🌍:merge-maps map (symbol-value (read-from-string (getf trigger-plist :map))))))
(list :parameters
(list :map (🌍:merge-maps map (symbol-value (read-from-string (getf trigger-plist :map)))))))
@ -365,7 +366,7 @@ avoid triggering this."
(say 'player :eo "Vi teruras, Saŝa."
:en "You're the worst, Sasha.")
(move 'player '(:x 51 :y 19))
`((:return-2 ,(list :map (merge-maps map *casino-map*)))))))
`((:parameters ,(list :map (merge-maps map *casino-map*)))))))
@ -615,7 +616,7 @@ avoid triggering this."
(say 'flashback-casino-dealer
:eo "Nu, ĉiu krom li, metu viajn vetaĵojn. Ni komencos je la Nula Epoko!"
:en "As for the rest of you, place your bets. It's time for the Zeroth Era!")
`((:return-2 ,(list :map (merge-maps map *outdoors-map*))))))
`((:parameters ,(list :map (merge-maps map *outdoors-map*))))))
(defun flashback-casino-dialogue (map)
@ -638,18 +639,18 @@ avoid triggering this."
`((:en "IDK"
:selection 100 :selected t)
(:en "GO BACK"
:return nil)))
:drop 1)))
(defun main-menu ()
`((:en "PLAY" :eo "EKLUDI"
:selection 100 :selected t
:return ,(🌍:make-overworld-state *outdoors-map*))
:function ,(🌍:make-overworld-state *outdoors-map*))
(:en "SUBMENU" :eo "SUBMENUO" :row 1
:return ,(📋:make-menu-state (submenu)))
:function ,(📋:make-menu-state (submenu)))
(:en "TERURE" :eo "BADLY" :row 1)
(:en "QUIT" :eo "REZIGNI" :row 2
:return nil)))
:drop 1)))

View File

@ -145,6 +145,7 @@ That is, 0 for non-selected items and 100 for selected items."
(selected-item (nth (selected-menu-item-position menu-plist)
menu-plist))
(func (getf selected-item :function))
(exec (getf selected-item :exec))
(return-val-p (member :return selected-item))
(return-val (getf selected-item :return)))
(case (getf input :semantic)
@ -171,16 +172,9 @@ That is, 0 for non-selected items and 100 for selected items."
(':
nil)
(':🆗
(cond ((and func return-val-p)
(apply func '())
return-val)
(func
(apply func '()))
(return-val-p
return-val)
('t
't)))
(otherwise 't)))
(if (getf selected-item :exec)
(apply (getf selected-item :exec) '())
selected-item))))
't))

View File

@ -210,9 +210,9 @@ Returns parameters to be used in the next invocation of OVERWORLD-STATE."
(interaction (getf (cdr interactee) :interact)))
(if interaction
(apply (string->symbol interaction) (list map interactee-id))
(list :map map))))
(list :parameters (list :map map)))))
(':
(🎒:make-inventory-state map))
(list :function (🎒:make-inventory-state map)))
;; Simple up-down-left-right movements
(':
(move-player map :Δx 1))
@ -231,8 +231,8 @@ Returns parameters to be used in the next invocation of OVERWORLD-STATE."
(':
(move-player map :Δx 1 :Δy 1))
(otherwise
(list :map map))))
(list :map map)))
(list :parameters (list :map map)))))
(list :parameters (list :map map))))
(defun move-player (map &key (Δx 0) (Δy 0))
@ -244,7 +244,7 @@ Very kindly removes a list of parameters to be returned by the overworld state-f
(if (and trigger (getf trigger :function))
(apply (string->symbol (getf trigger :function))
(list map trigger))
(list :map map))))
(list :parameters (list :map map)))))
(defun move-entity (map entity-id &key (Δx 0) (Δy 0))