hourglass when script cannot be ended.

This commit is contained in:
Bryce Covert
2015-08-13 22:16:31 -07:00
parent ac3b8665ef
commit ffa264eb7b
14 changed files with 109 additions and 68 deletions

View File

@@ -75,3 +75,9 @@
not disappear, but then when he picks you up to eat you it is gone,
then when he puts you down it appears again, then it is gone again
during the animation when he drinks the potion.
+ only interact with something if you started your click on it
+ Frankie should talk less when you enter room
+ Frankie should say something "Shhh, Tick's here."
+ You can find Gandarf's stash too quickly
+Click on active item, move off, cursor is still active

View File

@@ -54,12 +54,17 @@
(reify IAction
(get-channel [_] c#)
~@forms))
(reset! ~entities (<!! c#)))))
(let [result# (<!! c#)]
(if (= :end result#)
(do
(println "ending script")
(throw (ex-info "User quit script" {:type :end-script})))
(reset! ~entities result#))))))
(defn change-script-state [entities state]
(run-action entities
(begin [this screen entities]
(assoc-in entities [:actions :script-running?] state))
(update-in entities [:actions] assoc :script-running? state :last-skip-type (if state :end nil)))
(continue [this screen entities] entities)
@@ -69,7 +74,7 @@
(terminate [this screen entities]
entities)
(skip-type [this screen entities]
:none)))
:skip)))
(defmacro get-script [entities & forms]
`(fn [starting-entities#]
@@ -172,7 +177,7 @@
(terminate [this screen entities]
entities)
(skip-type [this screen entities]
:none)))
:skip)))
@@ -271,7 +276,7 @@
(terminate [this screen entities] entities)
(skip-type [this screen entities] :none)))
(defn walk-to [entities target-id [final-x final-y] & {:keys [skip-type face force-dir]}]
(defn walk-to [entities target-id [final-x final-y] & {:keys [skip-type face force-dir stop?] :or {stop? true}}]
(let [{start-x :x start-y :y} (get-in @entities [:room :entities target-id])
final-x (int final-x)
final-y (int final-y)
@@ -330,7 +335,9 @@
(< (utils/dist final-x final-y from-x from-y) 1)))
(terminate [this screen entities]
(stop screen entities target-id :face face))
(if stop?
(stop screen entities target-id :face face)
entities))
(skip-type [this screen entities]
(or skip-type :none)))
(do-stop entities :ego :face face))))
@@ -425,7 +432,7 @@
(screen! @(resolve 'advent.screens.scene/scene) :on-reactivate)
entities)
(skip-type [this screen entities]
:none))
:skip))
(let [zipper (nth-child zipper @selected-index)
node (zip/node zipper)]

View File

@@ -16,12 +16,12 @@
(defn make [screen]
(rooms/make :music {:day :town-2 :night :night}
:interactions
{:left-dir {:box [0 131 127 224]
{:left-dir {:box [0 131 154 224]
:script (actions/get-script
entities
(actions/walk-to entities :ego [122 140])
(actions/walk-to entities :ego [122 140] :skip-type :end)
(actions/transition-background entities :outside-house [244 150])
(actions/walk-to entities :ego [195 140]))
(actions/walk-to entities :ego [158 110]))
:cursor :left}
#_:crack #_{:box [68 100 73 114]
:script (actions/get-script

View File

@@ -192,9 +192,9 @@
(defn attempt-walking-through-gate [entities]
(actions/walk-to entities :ego [157 83])
(actions/walk-to entities :ego [157 83] :skip-type :end)
(actions/transition-background entities :inside-castle [280 145])
(actions/walk-to entities :ego [245 90]))
(actions/walk-to entities :ego [245 90] :skip-type :end))
(defn flip-coin [screen entities]
(if (and (= 0 (rand-int 2))
@@ -217,12 +217,12 @@
walkie-invisible (animation 1.0 [(first (utils/split-texture "castle-gate/throw-walkie.png" [205 136] (range 9)))])]
(rooms/make :music {:day :town-2 :night :night}
:timers {:taunt [1.0 6.0 flip-coin]}
:interactions {:right-dir {:box [300 40 320 83]
:interactions {:right-dir {:box [280 40 320 83]
:script (actions/get-script entities
(actions/walk-to entities :ego [301 46] :face :right)
(actions/walk-to entities :ego [301 46] :face :right :skip-type :end)
(actions/walk-straight-to entities :ego [340 40])
(actions/transition-background entities :outside-castle [82 180])
(actions/walk-to entities :ego [129 148]))
(actions/walk-to entities :ego [129 148] :skip-type :end))
:cursor :right}
:left-dir {:box [105 93 169 212]
:script (actions/get-script entities (attempt-walking-through-gate entities))

View File

@@ -210,10 +210,10 @@
:interactions
{:down-dir {:box [150 0 270 20]
:script (actions/get-script entities
(actions/walk-to entities :ego [200 10])
(actions/walk-to entities :ego [200 10] :skip-type :end :stop? false)
(actions/walk-straight-to entities :ego [223 -51])
(actions/transition-background entities :outside-house [137 204])
(actions/walk-to entities :ego [195 140]))
(actions/walk-to entities :ego [158 110] :skip-type :end))
:cursor :down}
:ladder-area {:box [134 40 265 190]
:scripts {:ladder (actions/get-unsaved-script entities

View File

@@ -143,7 +143,7 @@
(actions/add-entity entities :teddy teddy)
(actions/remove-item entities :teddy)))
(actions/walk-to entities :ego [235 15])
(actions/walk-to entities :ego [235 15] :stop? false :skip-type :end)
(actions/walk-straight-to entities :ego [320 -5])
(actions/transition-background entities :inside-castle [182 90])
(actions/walk-to entities :ego [187 75]))}

View File

@@ -162,9 +162,9 @@
{:right-dir {:box [272 45 320 120]
:script (actions/get-script
entities
(actions/walk-to entities :ego [319 50])
(actions/walk-to entities :ego [319 50] :skip-type :end)
(actions/transition-background entities :inside-castle [65 150])
(actions/walk-to entities :ego [126 80]))
(actions/walk-to entities :ego [126 80] :skip-type :end))
:cursor :right}
}
:layers [(assoc (texture "inside-cafeteria/background.png") :x 0 :y 0 :baseline 0)

View File

@@ -359,14 +359,14 @@
{:right-door {:box [286 140 306 160]
:cursor :right
:script (actions/get-script entities
(actions/walk-to entities :ego [284 145])
(actions/walk-to entities :ego [284 145] :skip-type :end)
(actions/walk-straight-to entities :ego [295 145])
(actions/transition-background entities :outside-castle [61 182])
(actions/walk-straight-to entities :ego [82 180])
(actions/walk-to entities :ego [129 148]))}
(actions/walk-to entities :ego [129 148] :skip-type :end))}
:up-door {:box [50 150 70 170]
:script (actions/get-script entities
(actions/walk-to entities :ego [65 155])
(actions/walk-to entities :ego [65 155] :skip-type :end)
(if (= :night (get-in @entities [:state :time]))
(actions/talk entities :ego "It's locked.")
(do (actions/transition-background entities :inside-cafeteria [319 55])
@@ -375,7 +375,7 @@
:antique-door {:box [154 90 189 150]
:cursor :up
:script (actions/get-script entities
(actions/walk-to entities :ego [182 90] :face :left)
(actions/walk-to entities :ego [182 90] :face :left :skip-type :end)
(actions/play-animation entities :ego :reach)
(if (= :night (get-in @entities [:state :time]))
@@ -407,7 +407,7 @@
(actions/talk entities :ego "Ye Ol' Antique Shoppe."))}
:background-houses {:box [84 145 126 180]
:script (actions/get-script entities
(actions/walk-to entities :ego [79 145] :face :right :stop? false)
(actions/walk-to entities :ego [79 145] :face :right :stop? false :skip-type :end)
(actions/walk-straight-to entities :ego [92 150] :face :right)
(actions/transition-background entities :outside-jail [159 -20])
(actions/walk-straight-to entities :ego [159 20]))

View File

@@ -133,10 +133,10 @@
candle-aura (utils/make-anim (texture "inside-house/candle-aura.png") [27 27] 0.2 [0 1 2 3 2 1] )
experiment-left (utils/flip (utils/make-anim (texture "wizard/experiment.png" ) [45 55] 0.075 [0 0 0 0 0 0 0 0 0 0 1 1 2 2 2 2 3 3 3 4 4 5 5 6 6 6 6 6 6 7 8 9 9 10 10 11 11 12 12 12 12 12 12 12 12 12 12 12 13 13 14 14 14 14 14 15 15 16 16 17 17 18 18 18 18 19 20 21 21 21 21 21 21 22 23 22 23 22 23 22 23 23 23 23 23 23 23 23 24 24 24 24 24 24 24 24 24 25 26 27 37 38 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 29 29 29 28 28 28 28 29 29 28 28 28 28 28 28 28 28 30 30 30 30 31 32 33 31 31 31 31 31 31 31 31 34 35 36 36 36 36 36 36 36 36 36] ))]
(rooms/make :music :inside-fangald
:interactions {:down-dir {:box [151 0 320 20]
:interactions {:down-dir {:box [151 0 320 40]
:script (actions/get-script entities
(actions/update-state entities #(assoc % :wizard-left? false))
(actions/walk-to entities :ego [237 1])
(actions/walk-to entities :ego [237 1] :stop? false :skip-type :end)
(actions/walk-straight-to entities :ego [245 -60])
(actions/transition-background entities :outside-house [257 90] :face :left))
:cursor :down}

View File

@@ -241,13 +241,13 @@
(defn go-through-gate [entities]
(if (should-block? entities)
(do
(actions/walk-to entities :ego [82 180] :face :left)
(actions/walk-to entities :ego [82 180] :face :left :skip-type :end)
(block-entrance entities))
(do
(actions/walk-to entities :ego [82 180])
(actions/walk-to entities :ego [82 180] :skip-type :end :stop? false)
(actions/walk-straight-to entities :ego [61 182])
(actions/transition-background entities :inside-castle [295 145])
(actions/walk-to entities :ego [245 90]))))
(actions/walk-to entities :ego [245 90] :skip-type :end))))
(defn add-note-if-necessary [entities]
@@ -280,12 +280,12 @@
flies-stand (utils/make-anim "outside-castle/flies.png" [15 15] 0.075 (flatten (repeat 2 [0 1 2 1])))]
(rooms/make :music {:day :town-2 :night :night :sunrise :night}
:interactions
{:right-dir {:box [300 40 320 140]
{:right-dir {:box [280 40 320 140]
:script (actions/get-script
entities
(actions/walk-to entities :ego [310 80])
(actions/walk-to entities :ego [310 80] :stop? false :skip-type :end)
(actions/walk-straight-to entities :ego [340 80])
(actions/transition-background entities :outside-house [0 80])
(actions/transition-background entities :outside-house [-10 80])
(actions/walk-straight-to entities :ego [30 80]))
:cursor :right}
:door {:box [66 180 85 195]

View File

@@ -42,13 +42,12 @@
(defn walk-to-castle [entities dawn?]
(actions/walk-to entities :ego [0 80])
(defn walk-to-castle [entities]
(actions/walk-to entities :ego [0 80] :skip-type :end)
(actions/walk-straight-to entities :ego [-20 80])
(if dawn?
(actions/transition-background entities :outside-castle [330 80])
(actions/transition-background entities :outside-castle [330 80]))
(actions/walk-straight-to entities :ego [310 80]))
(actions/transition-background entities :outside-castle [330 80])
(actions/walk-straight-to entities :ego [319 80] :stop? false)
(actions/walk-to entities :ego [273 81] :skip-type :end))
(def ego-sheep-loc
[132 140])
@@ -67,7 +66,7 @@
(not (actions/has-item? entities :money))))
(defn walk-to-sheep [entities]
(actions/walk-to entities :ego [154 133])
(actions/walk-to entities :ego [154 133] :skip-type :end)
(actions/walk-straight-to entities :ego [119 134] :update-baseline? false))
(defn leave-sheep [entities]
@@ -118,7 +117,7 @@
:ego "And just in time, too. It's getting light.")
(actions/update-state entities #(assoc % :next-time :sunrise :seen-bloodclot? false))
(walk-to-castle entities true)
(walk-to-castle entities)
(outside-castle/go-through-gate entities)
(actions/update-state entities #(assoc % :next-time :day))
(inside-castle/walk-to-blergh entities)
@@ -557,7 +556,7 @@
:script
(actions/get-script
entities
(actions/walk-to entities :ego [257 90] :face :right)
(actions/walk-to entities :ego [257 90] :face :right :skip-type :end)
(actions/talk entities :ego (str "Anyone home?"))
(actions/play-animation entities :ego :reach)
(if (= :night (get-in @entities [:state :time]))
@@ -580,21 +579,21 @@
:right-dir {:box [220 141 320 204]
:script (actions/get-script
entities
(actions/walk-to entities :ego [244 150])
(actions/walk-to entities :ego [244 150] :skip-type :end)
(actions/transition-background entities :behind-house [122 140])
(actions/walk-to entities :ego [172 122]))
:cursor :right}
:up-dir {:box [105 180 203 240]
:script (actions/get-script
entities
(actions/walk-to entities :ego [137 204])
(actions/walk-to entities :ego [137 204] :skip-type :end)
(actions/transition-background entities :cat-tree [223 -51])
(actions/walk-straight-to entities :ego [200 10]))
:cursor :up}
:left-dir {:box [0 40 20 140]
:left-dir {:box [0 40 40 140]
:script (actions/get-script
entities
(walk-to-castle entities false))
(walk-to-castle entities))
:cursor :left}}
:layers {:day [(assoc (texture "outsidehouse/background.png") :x 0 :y 0 :baseline 0)
(assoc (texture "outsidehouse/house.png") :x 0 :y 0 :baseline 122)

View File

@@ -108,18 +108,17 @@
(rooms/make :music {:day :town-1 :night :night}
:interactions {:down-dir {:box [30 0 227 20]
:script (actions/get-script entities
(actions/walk-to entities :ego [159 5])
(actions/walk-to entities :ego [159 5] :skip-type :end :stop? false)
(actions/walk-straight-to entities :ego [159 -20])
(actions/transition-background entities :inside-castle [92 150])
(actions/walk-straight-to entities :ego [79 145] :stop? false)
(actions/walk-to entities :ego [159 74]))
(actions/walk-to entities :ego [159 74] :skip-type :end))
:cursor :down}
:door {:box [22 42 46 124]
:script (actions/get-script entities
(if (= :night (get-in @entities [:state :time]))
(actions/talk entities :ego "I do NOT want to go back in there!")
(do (actions/walk-to entities :ego [50 46])
(actions/play-animation entities :ego :idea)
(actions/talk entities :warden "NO VISITORS!"))))}
:window {:box [62 175 80 212]
:script (actions/get-script entities

View File

@@ -204,7 +204,7 @@ void main()
(def default-interaction
{:get-script (fn [cursor [x y]] (if (= :main cursor)
(actions/get-script entities
(actions/walk-to entities :ego [x y] :skip-type :skip))
(actions/walk-to entities :ego [x y] :skip-type :end))
(actions/get-script entities
(actions/talk entities :ego "I don't know what to do with that."))))})
@@ -221,6 +221,24 @@ void main()
(assoc-in [:cursor :override] nil)))
(assoc-in entities [:cursor :current] :main))))
(defn skip-action [screen entities]
(let [current-action (get-in entities [:actions :current])]
(cond (= :skip (actions/skip-type 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))))
(= :end (actions/skip-type current-action screen entities))
(let [terminated-entities (actions/terminate current-action screen entities)]
(do (put! (actions/get-channel current-action) :end)
(-> terminated-entities
(assoc-in [:actions :script-running?] false)
(assoc-in [:actions :current] nil)
(assoc-in [:actions :started?] false))))
:else
entities)))
(defn left-click [screen entities]
(let [[x y] (utils/unproject screen)]
@@ -238,13 +256,10 @@ void main()
current-action (get-in entities [:actions :current])
;; TODO - hacky way of resetting queue
entities (if (and current-action (= :skip (actions/skip-type 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))))
entities)]
entities (if current-action
(skip-action screen entities)
entities)]
(if (get-in entities [:actions :script-running?])
entities
@@ -598,10 +613,12 @@ void main()
(let [terminated (actions/terminate current screen entities)]
(put! (actions/get-channel current) terminated)
(recur screen (assoc terminated
:actions {:channel channel :current nil :started? false :script-running? (get-in entities [:actions :script-running?])})))
:actions {:channel channel :current nil :started? false :script-running? (get-in entities [:actions :script-running?]) :last-skip-type (get-in entities [:actions :last-skip-type])})))
(assoc-in entities [:actions :started?] true)))
(let [[current _] (alts!! [channel] :default nil)]
(assoc entities :actions {:channel channel :current current :started? false :script-running? (get-in entities [:actions :script-running?])}))))
(assoc entities :actions {:channel channel :current current :started? false :script-running? (get-in entities [:actions :script-running?]) :last-skip-type (if current
(actions/skip-type current screen entities)
(get-in entities [:actions :last-skip-type]))}))))
(defn update-from-hotspots [screen entities]
@@ -616,6 +633,8 @@ void main()
(when-not (and (= new-current
last)
(= active was-active))
(when (= :last :hourglass)
(println new-current))
(let [image-path (if active "cursor_light.png" "cursor.png")]
(input! :set-cursor-image (utils/cursor image-path (or (:cursor new-current) new-current)) 0 0)))
(assoc-in entities [:cursor :last] new-current)))

View File

@@ -237,24 +237,35 @@
(and (< x1 x (+ x1 width))
(< y1 y (+ y1 height))))
(defn is-unstoppable-script-running [screen entities]
(let [current-action (get-in entities [:actions :current])
is-script-running (get-in entities [:actions :script-running?])]
(and is-script-running
(= :none (get-in entities [:actions :last-skip-type])))))
(defn update-override [screen entities]
(let [last-pos (unproject screen (get-in entities [:cursor :last-pos]))]
(if (get-in entities [:state :active?])
(if (get-in entities [:state :hud-active?])
(if (is-unstoppable-script-running screen entities)
(-> entities
(assoc-in [:cursor :override] nil)
(assoc-in [:cursor :override] :hourglass)
(assoc-in [:cursor :was-active] (get-in entities [:cursor :active]))
(assoc-in [:cursor :active] false))
(if-let [mouse-override (find-override entities last-pos)]
(-> entities
(assoc-in [:cursor :override] (or (:cursor mouse-override) (when (#{:main :active-main} (get-in entities [:cursor :last])) :active-main)))
(assoc-in [:cursor :was-active] (get-in entities [:cursor :active]))
(assoc-in [:cursor :active] true))
(if (get-in entities [:state :hud-active?])
(-> entities
(assoc-in [:cursor :override] nil)
(assoc-in [:cursor :was-active] (get-in entities [:cursor :active]))
(assoc-in [:cursor :active] false))))
(assoc-in [:cursor :active] false))
(if-let [mouse-override (find-override entities last-pos)]
(-> entities
(assoc-in [:cursor :override] (or (:cursor mouse-override) (when (#{:main :active-main} (get-in entities [:cursor :last])) :active-main)))
(assoc-in [:cursor :was-active] (get-in entities [:cursor :active]))
(assoc-in [:cursor :active] true))
(-> entities
(assoc-in [:cursor :override] nil)
(assoc-in [:cursor :was-active] (get-in entities [:cursor :active]))
(assoc-in [:cursor :active] false)))))
entities)))
(def default-night-merge {:r 0.08 :g 0.1 :b 0.36 :multiply-amount 1.0 :hue-amount 1.0})