good sounds.

This commit is contained in:
2015-02-21 11:11:43 -08:00
parent 201a428d7d
commit ed0ddefa3f
7 changed files with 36 additions and 22 deletions

View File

@@ -307,21 +307,21 @@
(get-in ego [:right :walk]) {2 [:step-sound-1 1.0]
6 [:step-sound-2 0.8]}
(get-in ego [:left :talk] ) {2 [:blink 0.2]}
(get-in ego [:right :talk] ) {2 [:blink 0.2]}
(get-in ego [:left :talk] ) {2 [:blink 0.15]}
(get-in ego [:right :talk] ) {2 [:blink 0.15]}
(get-in ego [:left :stand]) {11 [:blink 0.20]
44 [:blink 0.20]
77 [:blink 0.20]
110 [:blink 0.20]
143 [:blink 0.20]
176 [:blink 0.20]}
(get-in ego [:right :stand]) {11 [:blink 0.20]
44 [:blink 0.20]
77 [:blink 0.20]
110 [:blink 0.20]
143 [:blink 0.20]
176 [:blink 0.20]}}
(get-in ego [:left :stand]) {11 [:blink 0.15]
44 [:blink 0.15]
77 [:blink 0.15]
110 [:blink 0.15]
143 [:blink 0.15]
176 [:blink 0.15]}
(get-in ego [:right :stand]) {11 [:blink 0.15]
44 [:blink 0.15]
77 [:blink 0.15]
110 [:blink 0.15]
143 [:blink 0.15]
176 [:blink 0.15]}}
:anim-merges {(get-in ego [:right :shock]) {:origin-x 15}
:default {:origin-x 9}})]
(actions/start-animation screen
@@ -404,23 +404,26 @@
entities))
(defn play-key-sounds [entities]
(doseq [[target {:keys [previous-frame-index current-frame-index anim-sound-frames anim x y] :as e}] entities]
(doseq [[target {:keys [previous-frame-index current-frame-index anim-sound-frames anim x y] :as e}] (get-in entities [:room :entities])]
(when (and (not= previous-frame-index current-frame-index)
((set (keys anim-sound-frames)) anim))
(when-let [[snd vol-scale] (get-in anim-sound-frames [anim current-frame-index])]
(println "play")
(let [vol (if (= target :ego)
(* (/ (get-in entities [:ego :scale-x]) 1.5) 0.75)
(* (/ (get-in entities [:room :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])
(get-in entities [:room :entities :ego :x])
(get-in entities [:room :entities :ego :y])
:y-sign 2.0
:x-sign (/ 1.0 (get-in entities [:ego :scale-x])))
:x-sign (/ 1.0 (get-in entities [:room :entities :ego :scale-x])))
175.0))))
vol (* vol vol-scale)
vol (max vol 0.005)]
(sound! (snd e) :play vol))))))
(println vol snd)
(sound! (or (snd e)
(snd (:sounds entities))) :play vol))))))
(defscreen scene
@@ -461,6 +464,9 @@
:pull-sword (utils/make-music "pull-sword.ogg")
:night (utils/make-music "night.ogg")}
:state (get-state)
:sounds {:blink (sound "blink-other.ogg")
:object nil}
:fade (assoc (texture "black.png")
:scale-x 20
:scale-y 20
@@ -547,7 +553,7 @@
(when (= (get-in entities [:fade :opacity])
0.0)
(play-key-sounds (get-in entities [:room :entities])))
(play-key-sounds entities))
(doseq [m (vals (get-in entities [:musics]))]
(when m
(music! m :set-volume (get-in entities [:volume :value]))))