diff --git a/flora-search-aurora.lisp b/flora-search-aurora.lisp index 189b7a1..4294881 100644 --- a/flora-search-aurora.lisp +++ b/flora-search-aurora.lisp @@ -38,8 +38,12 @@ (print "OWO")) (defun literary-girl-dialogue (map) - (print "uwu") - (setf (getf-entity-data map 'literary-girl :interact) "literary-girl-dialogue-2")) + (lambda (matrix &key (map map) + (dialogue + `((:speaker "literary-girl" :face "xDx" :text "daddy") + (:speaker "player" :face "<3" :text "i love u")))) + (overworld-state-draw matrix map) + (dialogue-state matrix :map map :dialogue dialogue))) (defun state-loop @@ -61,19 +65,22 @@ If this function returns anything else, then it’ll simply be run again in the Make note to add a delay w SLEEP to your state functions, or… well, y’know. Your computer will overheat, or something ¯\_(ツ)_/¯" (when states - (let ((state-result - (apply (car states) (cons matrix state-params)))) ;; Run the latest-added update/draw loop - (print-screen-matrix (matrix-delta last-matrix matrix)) ;; Print its results. - (force-output) - (state-loop - (cond ((functionp state-result) - (cons state-result states)) - ((not state-result) - (cdr states)) - ('t states)) - :last-matrix matrix - :state-params (when (listp state-result) - state-result))))) + (multiple-value-bind (state-result new-state-params) + (apply (car states) (cons matrix state-params)) ;; Run the latest-added update/draw loop + (print-screen-matrix (matrix-delta last-matrix matrix)) ;; Print its results. + (force-output) + (state-loop + (cond ((functionp state-result) + (cons state-result 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)))))) (defun make-main-menu-state () @@ -124,4 +131,4 @@ with STATE-LOOP." ;; — Who’s there? ;; — Yo momma! ;; — “Yo momma” who? -;; — Yo momma’s a sweet lady, and I think she’s swell! +;; — Yo momma’s a sweet lady, and I’d like to take her out for some tea! diff --git a/overworld.lisp b/overworld.lisp index e7e936f..8d873ef 100644 --- a/overworld.lisp +++ b/overworld.lisp @@ -22,7 +22,8 @@ (:use :cl :flora-search-aurora.input :flora-search-aurora.display :flora-search-aurora.ui :flora-search-aurora.overworld.tiled :flora-search-aurora.overworld.util) - (:export #:overworld-state + (:export #:overworld-state #:overworld-state-draw + #:dialogue-state #:getf-entity #:getf-entity-data :player)) @@ -110,8 +111,7 @@ Uses the keys of plist a." (defun overworld-state-update (map) "Do nothing, lol. Core part of OVERWORLD-STATE. Returns parameters to be used in the next invocation of OVERWORLD-STATE." - (process-overworld-input map) - (list :map map)) + (process-overworld-input map)) (defun process-overworld-input (map) @@ -125,16 +125,24 @@ Returns parameters to be used in the next invocation of OVERWORLD-STATE." (interactee (car (entities-near-entity player (gethash :entities map)))) (interaction (getf (cdr interactee) :interact))) (if interaction - (apply (intern (string-upcase interaction)) (list map))))) + (apply (intern (string-upcase interaction)) (list map)) + (list :map map)))) ;; Simple up-down-left-right movements ((plist= input '(:modifier nil :char #\→)) - (move-entity map 'player :x 1)) + (move-entity map 'player :x 1) + (list :map map)) ((plist= input '(:modifier nil :char #\←)) - (move-entity map 'player :x -1)) + (move-entity map 'player :x -1) + (list :map map)) ((plist= input '(:modifier nil :char #\↑)) - (move-entity map 'player :y -1)) + (move-entity map 'player :y -1) + (list :map map)) ((plist= input '(:modifier nil :char #\↓)) - (move-entity map 'player :y 1)))))) + (move-entity map 'player :y 1) + (list :map map)) + ('t + (list :map map)))) + (list :map map))) (defun move-entity (map entity-id &key (x 0) (y 0)) @@ -246,3 +254,35 @@ A state-function for use with STATE-LOOP." (overworld-state-draw matrix map) (overworld-state-update map)) + + +;;; ——————————————————————————————————— +;;; Dialogue state +;;; ——————————————————————————————————— +(defun dialogue-state-update (dialogue-list map) + (if dialogue-list + (let ((speaker (intern (string-upcase (getf (car dialogue-list) :speaker)))) + (face (getf (car dialogue-list) :face))) + (setf (getf-entity-data map speaker :face) face))) + + (cond ((and dialogue-list + (listen) + (eq (getf (normalize-char-plist (read-char-plist)) + :char) + #\return)) + (list :dialogue (cdr dialogue-list) :map map)) + (dialogue-list + (list :dialogue dialogue-list :map map)) + ('t + (values nil + (list :map map))))) + + +(defun dialogue-state-draw (matrix dialogue-list) + (render-line matrix (getf (car dialogue-list) :text) 0 0)) + + +(defun dialogue-state (matrix &key dialogue map) + (sleep .02) + (dialogue-state-draw matrix dialogue) + (dialogue-state-update dialogue map)) diff --git a/ui.lisp b/ui.lisp index 8d24152..9c9dcc3 100644 --- a/ui.lisp +++ b/ui.lisp @@ -19,7 +19,9 @@ (defpackage :flora-search-aurora.ui (:use :cl :flora-search-aurora.display :flora-search-aurora.input :assoc-utils) - (:export #:menu-state #:render-line :label :selection :selected)) + (:export #:menu-state + #:render-line + :label :selection :selected)) (in-package :flora-search-aurora.ui) @@ -276,4 +278,3 @@ In addition, the resultant value shall not “pass” zero." ;;"---{============= -------------------" ;; | Kill your mom | Give into despair ;; ---{============= ------------------- -