water sounds nice.

This commit is contained in:
2015-05-29 20:04:11 -07:00
parent 0045dbcde7
commit 59a2df0788
6 changed files with 53 additions and 24 deletions

View File

@@ -81,6 +81,9 @@
(actions/walk-straight-to entities :ego [142 96])
(actions/talk entities :ego "This must be Frankie Rockfist's secret stash!")))
(defn fountain-vol [entities]
(utils/proximity-volume entities [172 120] :scale 0.5))
(defn make [screen]
(let [guard-sheet (texture! (texture "inside-cafeteria/ladder-guard.png") :split 37 87)
guard-stand (animation 0.1 [(aget guard-sheet 0 0)])
@@ -192,6 +195,8 @@
:y 140
:baseline 114)
:axe (assoc (texture "outside-jail/axe.png") :x 213 :y 63 :baseline 176 :night-profile :sprite)}
:fountain-sound {:sound (sound "outside-jail/fountain-2.ogg")
:id nil}
@@ -224,11 +229,24 @@
:collision "outside-jail/collision.png"
:scale-fn (utils/scaler-fn-with-baseline 40 0.001 1.3)
:start-pos [145 15]
:update-fn (fn [_ entities]
(when-let [fountain-sound-id (get-in entities [:room :fountain-sound :id])]
(sound! (get-in entities [:room :fountain-sound :sound]) :set-volume fountain-sound-id (fountain-vol entities)))
entities)
:stop-fn (fn [_ entities]
(when-let [fountain-sound-id (get-in entities [:room :fountain-sound :id])]
(sound! (get-in entities [:room :fountain-sound :sound]) :stop fountain-sound-id))
entities)
:apply-state (fn [_ entities]
(as-> entities entities
(if (= :night (get-in entities [:state :time]))
(make-night entities)
entities)
(if (get-in entities [:state :dropped-ball?])
(update-in entities [:room :entities :guard] #(actions/start-animation % :sleep))
entities))))))
(assoc-in entities [:room :fountain-sound :id] (sound! (get-in entities [:room :fountain-sound :sound]) :loop (fountain-vol entities)))
(if (= :night (get-in entities [:state :time]))
(make-night entities)
entities)
(if (get-in entities [:state :dropped-ball?])
(update-in entities [:room :entities :guard] #(actions/start-animation % :sleep))
entities))))))