sound closeness

This commit is contained in:
2015-02-19 17:15:59 -08:00
parent b86d6869c3
commit 5fc4f20045
3 changed files with 28 additions and 13 deletions

View File

@@ -295,10 +295,10 @@
nil))
:x (first start-pos) :y (last start-pos)
:id "ego"}
ego (assoc ego :anim-sound-frames {(get-in ego [:left :walk]) {2 :step-sound-1
6 :step-sound-2}
(get-in ego [:right :walk]) {2 :step-sound-1
6 :step-sound-2}}
ego (assoc ego :anim-sound-frames {(get-in ego [:left :walk]) {2 [:step-sound-1 1.0]
6 [:step-sound-2 0.8]}
(get-in ego [:right :walk]) {2 [:step-sound-1 1.0]
6 [:step-sound-2 0.8]}}
:anim-merges {(get-in ego [:right :shock]) {:origin-x 15}
:default {:origin-x 9}})]
(actions/start-animation screen
@@ -370,11 +370,22 @@
:seen-intro? false}))
(defn play-key-sounds [entities]
(doseq [{:keys [previous-frame-index current-frame-index anim-sound-frames anim] :as e} (vals entities)]
(doseq [[target {:keys [previous-frame-index current-frame-index anim-sound-frames anim x y] :as e}] entities]
(when (and (not= previous-frame-index current-frame-index)
((set (keys anim-sound-frames)) anim))
(when-let [snd (get-in anim-sound-frames [anim current-frame-index])]
(sound! (snd e) :play (* (/ (get-in entities [:ego :scale-x]) 1.5) 0.75))))))
(when-let [[snd vol-scale] (get-in anim-sound-frames [anim current-frame-index])]
(let [vol (if (= target :ego)
(* (/ (get-in entities [:ego :scale-x]) 1.5) 0.75)
(max 0.0
(- 1.0 (/ (utils/dist x y
(get-in entities [:ego :x])
(get-in entities [:ego :y])
:y-sign 2.0
:x-sign (/ 1.0 (get-in entities [:ego :scale-x])))
175.0))))
vol (* vol vol-scale)]
(when (> vol 0.05)
(sound! (snd e) :play vol)))))))
(defscreen scene