Start basic dialogue state, etc?

This is so bad, I wanna dieee :w:
This commit is contained in:
Jaidyn Ann 2023-06-17 22:47:30 -05:00
parent 6f60c76f4b
commit 218dcdc465
3 changed files with 74 additions and 26 deletions

View File

@ -38,8 +38,12 @@
(print "OWO")) (print "OWO"))
(defun literary-girl-dialogue (map) (defun literary-girl-dialogue (map)
(print "uwu") (lambda (matrix &key (map map)
(setf (getf-entity-data map 'literary-girl :interact) "literary-girl-dialogue-2")) (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 (defun state-loop
@ -61,8 +65,8 @@ If this function returns anything else, then itll simply be run again in the
Make note to add a delay w SLEEP to your state functions, or well, yknow. Your computer will Make note to add a delay w SLEEP to your state functions, or well, yknow. Your computer will
overheat, or something ¯\_()_/¯" overheat, or something ¯\_()_/¯"
(when states (when states
(let ((state-result (multiple-value-bind (state-result new-state-params)
(apply (car states) (cons matrix state-params)))) ;; Run the latest-added update/draw loop (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. (print-screen-matrix (matrix-delta last-matrix matrix)) ;; Print its results.
(force-output) (force-output)
(state-loop (state-loop
@ -72,8 +76,11 @@ overheat, or something ¯\_(ツ)_/¯"
(cdr states)) (cdr states))
('t states)) ('t states))
:last-matrix matrix :last-matrix matrix
:state-params (when (listp state-result) :state-params
state-result))))) (cond ((not state-result)
new-state-params)
((listp state-result)
state-result))))))
(defun make-main-menu-state () (defun make-main-menu-state ()
@ -124,4 +131,4 @@ with STATE-LOOP."
;; — Whos there? ;; — Whos there?
;; — Yo momma! ;; — Yo momma!
;; — “Yo momma” who? ;; — “Yo momma” who?
;; — Yo mommas a sweet lady, and I think shes swell! ;; — Yo mommas a sweet lady, and Id like to take her out for some tea!

View File

@ -22,7 +22,8 @@
(:use :cl (:use :cl
:flora-search-aurora.input :flora-search-aurora.display :flora-search-aurora.ui :flora-search-aurora.input :flora-search-aurora.display :flora-search-aurora.ui
:flora-search-aurora.overworld.tiled :flora-search-aurora.overworld.util) :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 #:getf-entity #:getf-entity-data
:player)) :player))
@ -110,8 +111,7 @@ Uses the keys of plist a."
(defun overworld-state-update (map) (defun overworld-state-update (map)
"Do nothing, lol. Core part of OVERWORLD-STATE. "Do nothing, lol. Core part of OVERWORLD-STATE.
Returns parameters to be used in the next invocation of OVERWORLD-STATE." Returns parameters to be used in the next invocation of OVERWORLD-STATE."
(process-overworld-input map) (process-overworld-input map))
(list :map map))
(defun 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)))) (interactee (car (entities-near-entity player (gethash :entities map))))
(interaction (getf (cdr interactee) :interact))) (interaction (getf (cdr interactee) :interact)))
(if interaction (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 ;; Simple up-down-left-right movements
((plist= input '(:modifier nil :char #\→)) ((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 #\←)) ((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 #\↑)) ((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 #\↓)) ((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)) (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-draw matrix map)
(overworld-state-update 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))

View File

@ -19,7 +19,9 @@
(defpackage :flora-search-aurora.ui (defpackage :flora-search-aurora.ui
(:use :cl :flora-search-aurora.display :flora-search-aurora.input :assoc-utils) (: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) (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 ;; | Kill your mom | Give into despair
;; ---{============= ------------------- ;; ---{============= -------------------