first stateful interaction.
This commit is contained in:
@@ -125,3 +125,21 @@
|
||||
(run! dialogue/talking-screen :stop-talk :target-id target-id)
|
||||
(stop screen entities target-id))))
|
||||
(<!! c)))
|
||||
|
||||
(defn give [entities target-id item]
|
||||
(let [c (chan)]
|
||||
(put! (get-in entities [:actions :channel])
|
||||
(reify
|
||||
IAction
|
||||
(begin [this screen entities]
|
||||
(update-in entities [target-id :inventory] #(conj % item)))
|
||||
|
||||
(continue [this screen entities] entities)
|
||||
|
||||
(done? [this screen entities]
|
||||
true)
|
||||
|
||||
(terminate [this screen entities]
|
||||
(put! c entities)
|
||||
entities)))
|
||||
(<!! c)))
|
||||
|
||||
@@ -101,6 +101,7 @@
|
||||
:origin-x 9
|
||||
:origin-y 0
|
||||
:scaled true
|
||||
:inventory #{}
|
||||
:x 150 :y 95
|
||||
:id "ego"}]
|
||||
(merge (texture (animation! (:right ego) :get-key-frame 0.25)) ego)))
|
||||
@@ -223,7 +224,10 @@
|
||||
(actions/talk entities :ego (str "Aww, it's a cute little sheep.")))
|
||||
:touch
|
||||
(actions/get-script
|
||||
(actions/talk entities :ego "I guess his wool is shedding."))
|
||||
(if ((get-in entities [:ego :inventory]) :wool)
|
||||
(actions/talk entities :ego "The sheep has given me enough wool.")
|
||||
(do (actions/give entities :ego :wool)
|
||||
(actions/talk entities :ego "I guess his wool is shedding."))))
|
||||
nil)))]
|
||||
:scale-fn (scaler-fn-with-baseline 110 0.10 1.00)
|
||||
:layers [(assoc background :x 0 :y 0 :baseline 0)
|
||||
|
||||
Reference in New Issue
Block a user