first puzzle complete
This commit is contained in:
@@ -19,8 +19,10 @@
|
||||
(done? [this screen entities])
|
||||
(continue [this screen entities])
|
||||
(terminate [this screen entities])
|
||||
(can-skip? [this screen entities])
|
||||
(get-channel [this]))
|
||||
|
||||
|
||||
(defmacro get-script [entities & forms]
|
||||
`(fn [starting-entities#]
|
||||
(let [~entities (atom starting-entities#)]
|
||||
@@ -114,7 +116,9 @@
|
||||
(< (dist final-x final-y from-x from-y) 1)))
|
||||
|
||||
(terminate [this screen entities]
|
||||
(stop screen entities target-id)))
|
||||
(stop screen entities target-id))
|
||||
(can-skip? [this screen entities]
|
||||
false))
|
||||
@entities)))
|
||||
|
||||
(defn get-text-duration [text]
|
||||
@@ -147,7 +151,9 @@
|
||||
(run! dialogue/talking-screen :stop-talk :target-id target-id)
|
||||
(if stop?
|
||||
(stop screen entities target-id)
|
||||
entities)))))
|
||||
entities))
|
||||
(can-skip? [this screen entities]
|
||||
true))))
|
||||
|
||||
(defn something-else [zipper]
|
||||
(-> zipper zip/up zip/up))
|
||||
@@ -182,7 +188,9 @@
|
||||
|
||||
(terminate [this screen entities]
|
||||
(run! @(resolve 'advent.screens.scene/scene) :on-reactivate)
|
||||
entities))
|
||||
entities)
|
||||
(can-skip? [this screen entities]
|
||||
false))
|
||||
|
||||
(let [zipper (nth-child zipper @selected-index)
|
||||
node (zip/node zipper)]
|
||||
@@ -195,6 +203,16 @@
|
||||
(recur (next-choices zipper))
|
||||
(recur zipper)))))))
|
||||
|
||||
(defn update-state [entities f]
|
||||
(run-action entities
|
||||
(begin [this screen entities]
|
||||
(update-in entities [:state] f ))
|
||||
(continue [this screen entities] entities)
|
||||
(done? [this screen entities] true)
|
||||
(terminate [this screen entities]
|
||||
entities)
|
||||
(can-skip? [this screen entities]
|
||||
false)))
|
||||
|
||||
(defn give [entities target-id item]
|
||||
(run-action entities
|
||||
@@ -210,7 +228,9 @@
|
||||
(done? [this screen entities] true)
|
||||
|
||||
(terminate [this screen entities]
|
||||
entities)))
|
||||
entities)
|
||||
(can-skip? [this screen entities]
|
||||
false)))
|
||||
|
||||
(defn transition-background [entities new-background [x y]]
|
||||
(run-action entities
|
||||
@@ -231,7 +251,9 @@
|
||||
(>= (get-in entities [:transition :opacity]) 1.0))
|
||||
|
||||
(terminate [this screen entities]
|
||||
entities))
|
||||
entities)
|
||||
(can-skip? [this screen entities]
|
||||
false))
|
||||
(run-action entities
|
||||
(begin [this screen entities]
|
||||
(let [ego (get-in entities [:background :entities :ego])
|
||||
@@ -248,4 +270,7 @@
|
||||
(<= (get-in entities [:transition :opacity]) 0.0))
|
||||
|
||||
(terminate [this screen entities]
|
||||
(dissoc entities :transition))))
|
||||
(dissoc entities :transition))
|
||||
|
||||
(can-skip? [this screen entities]
|
||||
false)))
|
||||
|
||||
@@ -82,7 +82,7 @@
|
||||
:on-touch-down (fn [screen [entities]]
|
||||
(let [{:keys [x y]} (input->screen screen {:x (:input-x screen) :y (:input-y screen)})]
|
||||
(when (seq entities)
|
||||
(when (< y (* 30 (count entities)))
|
||||
(when (< y (* 30 (dec (count entities))))
|
||||
((get-in entities [:state :callback]) (int (/ y 30)))
|
||||
{}))))
|
||||
|
||||
|
||||
@@ -53,16 +53,22 @@
|
||||
|
||||
(let [interaction (first (filter #(mouse-in? % [x y])
|
||||
(get-in entities [:background :interactions])))
|
||||
;; TODO - hacky way of resetting queue
|
||||
entities (if-let [current-action (get-in entities [:actions :current])]
|
||||
(assoc (actions/terminate current-action screen entities)
|
||||
:actions {:channel (chan) :current nil :started? false})
|
||||
entities)
|
||||
script (or (when interaction
|
||||
(get-script interaction [x y]))
|
||||
(get-script default-interaction [x y]))]
|
||||
|
||||
(script entities)
|
||||
current-action (get-in entities [:actions :current])
|
||||
;; TODO - hacky way of resetting queue
|
||||
entities (if (and current-action (actions/can-skip? current-action screen entities))
|
||||
(let [terminated-entities (actions/terminate current-action screen entities)]
|
||||
(do (put! (actions/get-channel current-action) terminated-entities)
|
||||
(-> terminated-entities
|
||||
(assoc-in [:actions :current] nil)
|
||||
(assoc-in [:actions :started?] false))))
|
||||
(assoc-in entities [:actions :channel] (chan)))]
|
||||
|
||||
(if current-action
|
||||
entities
|
||||
((or (when interaction
|
||||
(get-script interaction [x y]))
|
||||
(get-script default-interaction [x y])) entities))
|
||||
entities))))
|
||||
|
||||
(defn flip [anim]
|
||||
@@ -159,6 +165,8 @@
|
||||
(apply do-dialogue entities :ego line more))
|
||||
|
||||
(defn wizard-dialogue [entities]
|
||||
(do-dialogue entities :ego "Hello there Mr. Fangald!" :wizard "Oh no, not you again!")
|
||||
(actions/present-choices entities
|
||||
{:choices ["What do you mean, \"Not you again?\""
|
||||
{:run #(respond entities % :wizard "I mean, you've wrecked my life and I never want to see you again.")
|
||||
:choices ["You mean the time I set your house on fire with a fire mint?"
|
||||
@@ -215,27 +223,27 @@
|
||||
:wizard "'Worthy in courage, wisdom and might,' ..."
|
||||
:wizard "... 'only then with sword he'll fight.'"
|
||||
:wizard "'But a hero should he prove not be,' ..."
|
||||
:wizard "... 'Only ruin will fall on thee.'"
|
||||
:wizard "'I'll fall neither for guile nor guise'..."
|
||||
:wizard "... 'Only ruin will fall on he.'"
|
||||
:wizard "'Should he use guile or guise'..."
|
||||
)
|
||||
:choices ["Is this almost over?"
|
||||
{:run #(do (respond entities %
|
||||
{:run #(do (actions/update-state (fn [state] (assoc state :convinced-wizard? true)))
|
||||
(respond entities %
|
||||
:wizard "Patience, boy."
|
||||
:wizard "... 'Such a man will have great surprise.'"
|
||||
:wizard "If this is truely your quest, boy, then I will help you in your quest. "
|
||||
:wizard "But heed the warning from the prophecy: No cheat can pull the Sword of Blergh."
|
||||
:ego "No cheating."
|
||||
:ego "Check.")
|
||||
(swap! entities (fn [e] (assoc-in e [:state :convinced-wizard?] true))))}
|
||||
:ego "Check."))}
|
||||
"*cough* *cough* *ahem*"
|
||||
{:run #(do (respond entities %
|
||||
:wizard "Excuse you."
|
||||
{:run #(do (actions/update-state entities (fn [state] (assoc state :convinced-wizard? true)))
|
||||
(respond entities %
|
||||
:wizard "Excuse you. Moving on..."
|
||||
:wizard "... 'Such a man will have great surprise.'"
|
||||
:wizard "If this is truely your quest, boy, then I will help you in your quest. "
|
||||
:wizard "But heed the warning from the prophecy: No cheat can pull the Sword of Blergh."
|
||||
:ego "No cheating."
|
||||
:ego "Check.")
|
||||
(swap! entities (fn [e] (assoc-in e [:state :convinced-wizard?] true))))}]}
|
||||
:ego "Check."))}]}
|
||||
"By besting swamp, foe, and the occasional bizarre conversation tree."
|
||||
{:run #(do (respond entities %
|
||||
:wizard "While your goal sounds noble, no amount of bizarre conversation tree searching will earn my respect."
|
||||
@@ -247,7 +255,7 @@
|
||||
"Good bye, Mr. Fangald!"
|
||||
{:run #(do
|
||||
(respond entities % :wizard "Now scram!")
|
||||
(actions/transition-background entities :outside-house [262 88]))}]})
|
||||
(actions/transition-background entities :outside-house [262 88]))}]}))
|
||||
|
||||
(defn backgrounds [screen]
|
||||
(let [sheep-sheet (texture! (texture "outsidehouse/sheep-anim.png") :split 33 21)
|
||||
@@ -270,10 +278,7 @@
|
||||
(actions/walk-to entities :ego [237 1])
|
||||
(actions/transition-background entities :outside-house [262 88]))
|
||||
:cursor :down}
|
||||
:wizard {:box [228 80 248 126]
|
||||
:script (actions/get-script entities
|
||||
(do-dialogue entities :ego "Hello there Mr. Fangald!" :wizard "Oh no, not you again!")
|
||||
(actions/present-choices entities (wizard-dialogue entities)))}}
|
||||
:wizard {:box [228 80 248 126]}}
|
||||
:layers [(assoc (texture "inside-house/background.png") :x 0 :y 0 :baseline 0)
|
||||
(assoc (texture "inside-house/desk.png") :x 0 :y 0 :baseline 200)
|
||||
(assoc (texture "inside-house/sillhoute.png") :x 0 :y 0 :baseline 240)]
|
||||
@@ -293,7 +298,10 @@
|
||||
entities
|
||||
(actions/walk-to entities :ego [262 88])
|
||||
(actions/talk entities :ego (str "Anyone home?"))
|
||||
(actions/transition-background entities :inside-house [237 0]))}
|
||||
(actions/transition-background entities :inside-house [237 0])
|
||||
(if (get-in @entities [:state :convinced-wizard?])
|
||||
(actions/talk entities :wizard (str "Oh, hello there boy."))
|
||||
(wizard-dialogue entities)))}
|
||||
:sword {:box [274 55 305 88]
|
||||
:script (actions/get-script
|
||||
entities
|
||||
|
||||
Reference in New Issue
Block a user