lots of improvements.

This commit is contained in:
2014-10-01 13:26:56 -07:00
parent 4bd400dff3
commit d235017423
4 changed files with 77 additions and 26 deletions

View File

@@ -34,7 +34,7 @@
IInteractable
(get-script [_ [x y]]
(actions/get-script entities
(actions/walk-to entities :ego [x y])))))
(actions/walk-to entities :ego [x y] true)))))
(defn find-override [screen entities [x y]]
@@ -43,7 +43,8 @@
(get-in entities [:background :interactions]))))
(defn open-inventory [screen entities]
(run! inventory-screen :show-screen))
(run! inventory-screen :show-screen :items (get-in entities [:state :inventory]))
(assoc-in entities [:state :active?] false))
(defn left-click [screen entities]
@@ -103,7 +104,7 @@
:origin-x 9
:origin-y 0
:scaled true
:inventory #{}
:x 150 :y 95
:id "ego"}]
(actions/start-animation screen
@@ -227,7 +228,7 @@
:wizard "'Should he use guile or guise'..."
)
:choices ["Is this almost over?"
{:run #(do (actions/update-state (fn [state] (assoc state :convinced-wizard? true)))
{:run #(do (actions/update-state entities (fn [state] (assoc state :convinced-wizard? true)))
(respond entities %
:wizard "Patience, boy."
:wizard "... 'Such a man will have great surprise.'"
@@ -311,9 +312,9 @@
:sheep {:box [38 160 71 181]
:script (actions/get-script
entities
(if ((get-in @entities [:background :entities :ego :inventory]) :wool)
(if ((get-in @entities [:state :inventory]) :wool)
(actions/talk entities :ego "The sheep has given me enough wool.")
(do (actions/give entities :ego :wool)
(do (actions/give entities :wool)
(actions/talk entities :ego "I guess his wool is shedding."))))}
:right-dir {:box [300 131 320 224]
:script (actions/get-script
@@ -363,11 +364,11 @@
:mushrooms {:box [247 59 269 76]
:script (actions/get-script
entities
(if ((get-in @entities [:background :entities :ego :inventory]) :mushrooms)
(if ((get-in @entities [:state :inventory]) :mushrooms)
(actions/talk entities :ego "I've already got a junk ton of mushrooms.")
(do
(actions/walk-to entities :ego [242 75])
(actions/give entities :ego :mushrooms)
(actions/give entities :mushrooms)
(actions/talk entities :ego "Perfectly ripe mushrooms!"))))}
:window {:box [103 44 130 140]
:script (actions/get-script
@@ -437,11 +438,12 @@
(update! screen :renderer (stage) :camera (orthographic))
(let [_ (input! :set-cursor-image (utils/cursor "cursor.png" :main) 0 0)
music (sound "town-music.mp3")
_ (sound! music :loop 0.20)
;; _ (sound! music :loop 0.20)
backgrounds (backgrounds screen)]
{:backgrounds backgrounds
:state {:object nil
:active? true}
:active? true
:inventory (sorted-set)}
:actions {:object nil
:channel (chan)
:current nil
@@ -498,6 +500,9 @@
:on-reactivate (fn [screen [entities]]
(assoc-in entities [:state :active?] true))
:on-chose-item (fn [{:keys [item]} [entities]]
(assoc-in entities [:cursor :current] item))
:on-start-script (fn [{:keys [script]} [entities]]
(script entities)
entities))