Slightly tweak the engine thingy
This commit is contained in:
parent
1ab64221cd
commit
63515434d0
|
@ -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)
|
((or (and did-press-enter-p did-finish-printing-p did-finish-moving-p)
|
||||||
(and (not text) did-finish-moving-p))
|
(and (not text) did-finish-moving-p))
|
||||||
(if (cdr dialogue-list)
|
(if (cdr dialogue-list)
|
||||||
(list :dialogue (cdr dialogue-list) :map map)
|
(list :parameters (list :dialogue (cdr dialogue-list) :map map))
|
||||||
(progn
|
(progn
|
||||||
(✎:hide-cursor)
|
(✎:hide-cursor)
|
||||||
(values (or (getf dialogue :return) nil)
|
(list :drop 1
|
||||||
(or (getf dialogue :return-2)
|
:function (getf dialogue :function)
|
||||||
|
:parameters (or (getf dialogue :parameters)
|
||||||
(list :map map))))))
|
(list :map map))))))
|
||||||
;; Allow interupting text-printing to end it!
|
;; Allow interupting text-printing to end it!
|
||||||
((and did-press-enter-p (not did-finish-printing-p))
|
((and did-press-enter-p (not did-finish-printing-p))
|
||||||
(setf (getf (car dialogue-list) :progress) (length text))
|
(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!
|
;; If no input, keep steady!
|
||||||
('t
|
('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)
|
(defun make-dialogue-state (map dialogue-list)
|
||||||
"Return a state-function for a section of dialogue, for use with STATE-LOOP."
|
"Return a state-function for a section of dialogue, for use with STATE-LOOP."
|
||||||
|
(list :function
|
||||||
(lambda (matrix &key (map map) (dialogue dialogue-list))
|
(lambda (matrix &key (map map) (dialogue dialogue-list))
|
||||||
(🌍:overworld-state-draw matrix map)
|
(🌍: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,
|
;; Split a banana in two, bisection-fruit,
|
||||||
|
|
30
engine.lisp
30
engine.lisp
|
@ -31,31 +31,31 @@ to the terminal.
|
||||||
What the state-function returns is pretty important, having different repercussions:
|
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
|
* NIL — The function is removed from STATES, and so the next function in STATES will start
|
||||||
getting executed instead.
|
getting executed instead.
|
||||||
* NIL; List — The function is popped off STATES and the list is used as the new parameters for
|
* T — The function will continue to be run with the same parameters.
|
||||||
the next function in STATES.
|
* (:FUNCTION FUNCTION :PARAMETERS LIST :DROP NUMBER)
|
||||||
* 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.
|
|
||||||
Make note to add a delay w SLEEP to your state functions, or… well, y’know. Your computer will
|
Make note to add a delay w SLEEP to your state functions, or… well, y’know. Your computer will
|
||||||
overheat, or something ¯\_(ツ)_/¯"
|
overheat, or something ¯\_(ツ)_/¯"
|
||||||
(when states
|
(when states
|
||||||
(multiple-value-bind (state-result new-state-params)
|
(let ((state-result
|
||||||
(apply (car states) (cons matrix state-params)) ;; Run the latest-added update/draw loop
|
(apply (car states) (cons matrix state-params)))) ;; Run the last-added state-loop.
|
||||||
(✎:print-screen-matrix (✎:matrix-delta last-matrix matrix)) ;; Print its results.
|
(✎:print-screen-matrix (✎:matrix-delta last-matrix matrix)) ;; Print its results.
|
||||||
|
(format *error-output* "~S~%" state-result)
|
||||||
(force-output)
|
(force-output)
|
||||||
(state-loop
|
(state-loop
|
||||||
(cond ((functionp state-result)
|
(cond ((listp state-result)
|
||||||
(cons state-result states))
|
(nconc (if (getf state-result :function)
|
||||||
|
(list (getf state-result :function)))
|
||||||
|
(nthcdr (or (getf state-result :drop) 0) states)))
|
||||||
((not state-result)
|
((not state-result)
|
||||||
(cdr states))
|
(cdr states))
|
||||||
('t states))
|
('t states))
|
||||||
:last-matrix matrix
|
|
||||||
:state-params
|
:state-params
|
||||||
(cond ((not state-result)
|
(cond ((listp state-result)
|
||||||
new-state-params)
|
(getf state-result :parameters))
|
||||||
((listp state-result)
|
((not state-result)
|
||||||
state-result))))))
|
nil)
|
||||||
|
('t state-params))
|
||||||
|
:last-matrix matrix))))
|
||||||
|
|
||||||
|
|
||||||
(defun main (states)
|
(defun main (states)
|
||||||
|
|
|
@ -129,7 +129,8 @@ Useful for making barriers the player character refuses to traverse."
|
||||||
(defun entrance-trigger (map trigger-plist)
|
(defun entrance-trigger (map trigger-plist)
|
||||||
"A trigger that can be used to move the user from one MAP to another, via the
|
"A trigger that can be used to move the user from one MAP to another, via the
|
||||||
:MAP property in a trigger’s Tiled entity."
|
:MAP property in a trigger’s 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."
|
(say 'player :eo "Vi teruras, Saŝa."
|
||||||
:en "You're the worst, Sasha.")
|
:en "You're the worst, Sasha.")
|
||||||
(move 'player '(:x 51 :y 19))
|
(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
|
(say 'flashback-casino-dealer
|
||||||
:eo "Nu, ĉiu krom li, metu viajn vetaĵojn. Ni komencos je la Nula Epoko!"
|
: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!")
|
: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)
|
(defun flashback-casino-dialogue (map)
|
||||||
|
@ -638,18 +639,18 @@ avoid triggering this."
|
||||||
`((:en "IDK"
|
`((:en "IDK"
|
||||||
:selection 100 :selected t)
|
:selection 100 :selected t)
|
||||||
(:en "GO BACK"
|
(:en "GO BACK"
|
||||||
:return nil)))
|
:drop 1)))
|
||||||
|
|
||||||
|
|
||||||
(defun main-menu ()
|
(defun main-menu ()
|
||||||
`((:en "PLAY" :eo "EKLUDI"
|
`((:en "PLAY" :eo "EKLUDI"
|
||||||
:selection 100 :selected t
|
:selection 100 :selected t
|
||||||
:return ,(🌍:make-overworld-state *outdoors-map*))
|
:function ,(🌍:make-overworld-state *outdoors-map*))
|
||||||
(:en "SUBMENU" :eo "SUBMENUO" :row 1
|
(:en "SUBMENU" :eo "SUBMENUO" :row 1
|
||||||
:return ,(📋:make-menu-state (submenu)))
|
:function ,(📋:make-menu-state (submenu)))
|
||||||
(:en "TERURE" :eo "BADLY" :row 1)
|
(:en "TERURE" :eo "BADLY" :row 1)
|
||||||
(:en "QUIT" :eo "REZIGNI" :row 2
|
(:en "QUIT" :eo "REZIGNI" :row 2
|
||||||
:return nil)))
|
:drop 1)))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
14
menu.lisp
14
menu.lisp
|
@ -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)
|
(selected-item (nth (selected-menu-item-position menu-plist)
|
||||||
menu-plist))
|
menu-plist))
|
||||||
(func (getf selected-item :function))
|
(func (getf selected-item :function))
|
||||||
|
(exec (getf selected-item :exec))
|
||||||
(return-val-p (member :return selected-item))
|
(return-val-p (member :return selected-item))
|
||||||
(return-val (getf selected-item :return)))
|
(return-val (getf selected-item :return)))
|
||||||
(case (getf input :semantic)
|
(case (getf input :semantic)
|
||||||
|
@ -171,16 +172,9 @@ That is, 0 for non-selected items and 100 for selected items."
|
||||||
('⌨:❎
|
('⌨:❎
|
||||||
nil)
|
nil)
|
||||||
('⌨:🆗
|
('⌨:🆗
|
||||||
(cond ((and func return-val-p)
|
(if (getf selected-item :exec)
|
||||||
(apply func '())
|
(apply (getf selected-item :exec) '())
|
||||||
return-val)
|
selected-item))))
|
||||||
(func
|
|
||||||
(apply func '()))
|
|
||||||
(return-val-p
|
|
||||||
return-val)
|
|
||||||
('t
|
|
||||||
't)))
|
|
||||||
(otherwise 't)))
|
|
||||||
't))
|
't))
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -210,9 +210,9 @@ Returns parameters to be used in the next invocation of OVERWORLD-STATE."
|
||||||
(interaction (getf (cdr interactee) :interact)))
|
(interaction (getf (cdr interactee) :interact)))
|
||||||
(if interaction
|
(if interaction
|
||||||
(apply (string->symbol interaction) (list map interactee-id))
|
(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
|
;; Simple up-down-left-right movements
|
||||||
('⌨:→
|
('⌨:→
|
||||||
(move-player map :Δx 1))
|
(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))
|
(move-player map :Δx 1 :Δy 1))
|
||||||
(otherwise
|
(otherwise
|
||||||
(list :map map))))
|
(list :parameters (list :map map)))))
|
||||||
(list :map map)))
|
(list :parameters (list :map map))))
|
||||||
|
|
||||||
|
|
||||||
(defun move-player (map &key (Δx 0) (Δy 0))
|
(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))
|
(if (and trigger (getf trigger :function))
|
||||||
(apply (string->symbol (getf trigger :function))
|
(apply (string->symbol (getf trigger :function))
|
||||||
(list map trigger))
|
(list map trigger))
|
||||||
(list :map map))))
|
(list :parameters (list :map map)))))
|
||||||
|
|
||||||
|
|
||||||
(defun move-entity (map entity-id &key (Δx 0) (Δy 0))
|
(defun move-entity (map entity-id &key (Δx 0) (Δy 0))
|
||||||
|
|
Ŝarĝante…
Reference in New Issue