Run INTERACT function mentioned in Tiled map
This commit is contained in:
parent
c37ce281ea
commit
c801a2ddfb
|
@ -22,6 +22,7 @@
|
||||||
(load "input.lisp")
|
(load "input.lisp")
|
||||||
(load "display.lisp")
|
(load "display.lisp")
|
||||||
(load "ui.lisp")
|
(load "ui.lisp")
|
||||||
|
(load "tiled.lisp")
|
||||||
(load "overworld.lisp")
|
(load "overworld.lisp")
|
||||||
|
|
||||||
(defpackage :flora-search-aurora
|
(defpackage :flora-search-aurora
|
||||||
|
@ -33,6 +34,10 @@
|
||||||
(in-package :flora-search-aurora)
|
(in-package :flora-search-aurora)
|
||||||
|
|
||||||
|
|
||||||
|
(defun talk (map)
|
||||||
|
(print "AAAAA"))
|
||||||
|
|
||||||
|
|
||||||
(defun state-loop
|
(defun state-loop
|
||||||
(states &key (last-matrix (make-screen-matrix)) (matrix (make-screen-matrix)) (state-params nil))
|
(states &key (last-matrix (make-screen-matrix)) (matrix (make-screen-matrix)) (state-params nil))
|
||||||
"Begin the game’s loop, which executes (henceforthly called) state-functions over and over again
|
"Begin the game’s loop, which executes (henceforthly called) state-functions over and over again
|
||||||
|
@ -49,9 +54,8 @@ state-function in the next iteration, in addition to the aforementioned matrix.
|
||||||
If this function returns a function, then the returned function will go to the front of the
|
If this function returns a function, then the returned function will go to the front of the
|
||||||
state-function list, and will be ran in the next iteration onward.
|
state-function list, and will be ran in the next iteration onward.
|
||||||
If this function returns anything else, then it’ll simply be run again in the next iteration.
|
If this function returns anything else, then it’ll simply be run again in the next iteration.
|
||||||
Make note to add a delay to your state functions, or… well, y’know. Your computer will overheat,
|
Make note to add a delay w SLEEP to your state functions, or… well, y’know. Your computer will
|
||||||
or something ¯\_(ツ)_/¯"
|
overheat, or something ¯\_(ツ)_/¯"
|
||||||
|
|
||||||
(when states
|
(when states
|
||||||
(let ((state-result
|
(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 latest-added update/draw loop
|
||||||
|
@ -69,7 +73,7 @@ or something ¯\_(ツ)_/¯"
|
||||||
|
|
||||||
|
|
||||||
(defun make-main-menu-state ()
|
(defun make-main-menu-state ()
|
||||||
"Return a state-function for the game’s main menu, for use with #'state-loop."
|
"Return a state-function for the game’s main menu, for use with STATE-LOOP."
|
||||||
(let ((main-menu
|
(let ((main-menu
|
||||||
`(((LABEL . "PLAY")
|
`(((LABEL . "PLAY")
|
||||||
(SELECTION . 100) (SELECTED . T)
|
(SELECTION . 100) (SELECTED . T)
|
||||||
|
@ -82,7 +86,7 @@ or something ¯\_(ツ)_/¯"
|
||||||
|
|
||||||
|
|
||||||
(defun make-options-menu-state ()
|
(defun make-options-menu-state ()
|
||||||
"Return a state-function for the options menu, for use with #'state-loop."
|
"Return a state-function for the options menu, for use with STATE-LOOP."
|
||||||
(let ((options-menu
|
(let ((options-menu
|
||||||
`(((LABEL . "IDK")
|
`(((LABEL . "IDK")
|
||||||
(SELECTION . 100) (SELECTED . T)
|
(SELECTION . 100) (SELECTED . T)
|
||||||
|
@ -94,8 +98,8 @@ 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
|
||||||
#'state-loop."
|
with STATE-LOOP."
|
||||||
(lambda (matrix &rest args)
|
(lambda (matrix &rest args)
|
||||||
(apply #'overworld-state
|
(apply #'overworld-state
|
||||||
(append (list matrix)
|
(append (list matrix)
|
||||||
|
@ -106,6 +110,7 @@ or something ¯\_(ツ)_/¯"
|
||||||
(defun main ()
|
(defun main ()
|
||||||
"A pathetic fascimile of a main loop. What does it do? WHAST DOES TI DODOO?"
|
"A pathetic fascimile of a main loop. What does it do? WHAST DOES TI DODOO?"
|
||||||
(cl-charms:with-curses ()
|
(cl-charms:with-curses ()
|
||||||
|
(cl-charms/low-level:curs-set 0) ;; Hide the terminal cursor
|
||||||
(cl-charms:enable-raw-input :interpret-control-characters 't)
|
(cl-charms:enable-raw-input :interpret-control-characters 't)
|
||||||
(clear-screen)
|
(clear-screen)
|
||||||
(state-loop (list (make-main-menu-state)))))
|
(state-loop (list (make-main-menu-state)))))
|
||||||
|
|
|
@ -65,6 +65,10 @@ Returns parameters to be used in the next invocation of OVERWORLD-STATE."
|
||||||
(if (listen)
|
(if (listen)
|
||||||
(let* ((input (normalize-char-plist (read-char-plist))))
|
(let* ((input (normalize-char-plist (read-char-plist))))
|
||||||
(cond
|
(cond
|
||||||
|
((plist= input '(:modifier nil :char #\return))
|
||||||
|
(let ((interact (getf (cdr (assoc 'player (getf map :entities))) :interact)))
|
||||||
|
(if interact
|
||||||
|
(apply (intern interact) (list map)))))
|
||||||
((plist= input '(:modifier nil :char #\→))
|
((plist= input '(:modifier nil :char #\→))
|
||||||
(move-entity map 'player :x 1))
|
(move-entity map 'player :x 1))
|
||||||
((plist= input '(:modifier nil :char #\←))
|
((plist= input '(:modifier nil :char #\←))
|
||||||
|
@ -173,7 +177,7 @@ alist containing a character (:CHAR) and :X & :Y coordinates."
|
||||||
(cond ((eq direction 'right)
|
(cond ((eq direction 'right)
|
||||||
(ignore-errors (setf (aref matrix y x) #\|))
|
(ignore-errors (setf (aref matrix y x) #\|))
|
||||||
(ignore-errors (setf (aref matrix y (- x 1)) #\|)))
|
(ignore-errors (setf (aref matrix y (- x 1)) #\|)))
|
||||||
((eq direction 'left)
|
('t
|
||||||
(ignore-errors (setf (aref matrix y x) #\|))
|
(ignore-errors (setf (aref matrix y x) #\|))
|
||||||
(ignore-errors (setf (aref matrix y (+ x 1)) #\|))))))
|
(ignore-errors (setf (aref matrix y (+ x 1)) #\|))))))
|
||||||
|
|
||||||
|
|
14
res/map.tmx
14
res/map.tmx
|
@ -1,5 +1,5 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<map version="1.10" tiledversion="1.10.1" orientation="orthogonal" renderorder="left-down" width="144" height="40" tilewidth="12" tileheight="17" infinite="0" nextlayerid="10" nextobjectid="3">
|
<map version="1.10" tiledversion="1.10.1" orientation="orthogonal" renderorder="left-down" width="144" height="40" tilewidth="12" tileheight="17" infinite="0" nextlayerid="10" nextobjectid="5">
|
||||||
<tileset firstgid="1" source="font.tsx"/>
|
<tileset firstgid="1" source="font.tsx"/>
|
||||||
<layer id="1" name="Background" width="144" height="40">
|
<layer id="1" name="Background" width="144" height="40">
|
||||||
<properties>
|
<properties>
|
||||||
|
@ -98,9 +98,19 @@
|
||||||
<objectgroup id="7" name="Entities">
|
<objectgroup id="7" name="Entities">
|
||||||
<object id="2" name="Player" type="Entity" x="103" y="368">
|
<object id="2" name="Player" type="Entity" x="103" y="368">
|
||||||
<properties>
|
<properties>
|
||||||
<property name="face" value="uwu"/>
|
<property name="face" value="=w="/>
|
||||||
<property name="facing_right" type="bool" value="true"/>
|
<property name="facing_right" type="bool" value="true"/>
|
||||||
<property name="id" value="player"/>
|
<property name="id" value="player"/>
|
||||||
|
<property name="interact" value="TALK"/>
|
||||||
|
</properties>
|
||||||
|
<point/>
|
||||||
|
</object>
|
||||||
|
<object id="4" name="Literary girl" type="Entity" x="317.604" y="366.606">
|
||||||
|
<properties>
|
||||||
|
<property name="face" value="owo"/>
|
||||||
|
<property name="facing_right" type="bool" value="true"/>
|
||||||
|
<property name="id" value="literary-girl"/>
|
||||||
|
<property name="interact" value="flora-search-aurora::interact"/>
|
||||||
</properties>
|
</properties>
|
||||||
<point/>
|
<point/>
|
||||||
</object>
|
</object>
|
||||||
|
|
Ŝarĝante…
Reference in New Issue