sound progress.
This commit is contained in:
@@ -46,9 +46,7 @@
|
|||||||
(actions/has-obtained? entities :sword)
|
(actions/has-obtained? entities :sword)
|
||||||
0.0
|
0.0
|
||||||
:else
|
:else
|
||||||
(* (max 0.0 (- 1.0 (/ (utils/dist 45 97 (:x ego) (:y ego)) 50.0)))
|
(max 0.0 (- 1.0 (/ (utils/dist 45 97 (:x ego) (:y ego)) 50.0))))))
|
||||||
(- 1.0 (get-in entities [:fade :opacity]))
|
|
||||||
(get-in entities [:volume :value] 1.0)))))
|
|
||||||
|
|
||||||
(defn bloodclot-appear [entities]
|
(defn bloodclot-appear [entities]
|
||||||
(actions/run-action entities
|
(actions/run-action entities
|
||||||
@@ -626,9 +624,14 @@
|
|||||||
:chorus {:sound (utils/load-sound "inside-castle/chorus.ogg")}
|
:chorus {:sound (utils/load-sound "inside-castle/chorus.ogg")}
|
||||||
:collision "inside-castle/collision.png"
|
:collision "inside-castle/collision.png"
|
||||||
:scale-fn (utils/scaler-fn-from-image "inside-castle/scale.png" 0.25 1.00)
|
:scale-fn (utils/scaler-fn-from-image "inside-castle/scale.png" 0.25 1.00)
|
||||||
:apply-state (fn [_ entities]
|
:apply-state (fn [screen entities]
|
||||||
(utils/fast-forward-particle (get-in entities [:room :entities :outside-particles]))
|
(utils/fast-forward-particle (get-in entities [:room :entities :outside-particles]))
|
||||||
(as-> entities entities
|
(as-> entities entities
|
||||||
|
(utils/play-sound! screen entities
|
||||||
|
(get-in entities [:room :chorus :sound])
|
||||||
|
get-chorus-volume
|
||||||
|
0.5
|
||||||
|
:loop)
|
||||||
(if (actions/has-obtained? entities :trophy)
|
(if (actions/has-obtained? entities :trophy)
|
||||||
(update-in entities [:room :entities] #(dissoc % :trophy))
|
(update-in entities [:room :entities] #(dissoc % :trophy))
|
||||||
entities)
|
entities)
|
||||||
@@ -642,23 +645,5 @@
|
|||||||
(if (#{:night :sunrise} (get-in entities [:state :time]))
|
(if (#{:night :sunrise} (get-in entities [:state :time]))
|
||||||
(make-night entities)
|
(make-night entities)
|
||||||
entities)))
|
entities)))
|
||||||
:update-fn (fn [screen entities]
|
|
||||||
#_(when (and (actions/has-obtained? entities :sword)
|
|
||||||
(get-in entities [:room :entities :magic])
|
|
||||||
(particle-effect! (get-in entities [:room :entities :magic]) :is-complete))
|
|
||||||
)
|
|
||||||
(let [chorus-volume (get-chorus-volume entities)]
|
|
||||||
(if (= 0.0 chorus-volume)
|
|
||||||
(if (get-in entities [:room :chorus :instance])
|
|
||||||
(do (sound! (get-in entities [:room :chorus :sound]) :stop)
|
|
||||||
(update-in entities [:room :chorus] dissoc :instance))
|
|
||||||
entities)
|
|
||||||
(let [chorus (get-in entities [:room :chorus])]
|
|
||||||
(if (:instance chorus)
|
|
||||||
(do (sound! (:sound chorus) :set-volume
|
|
||||||
(:instance chorus)
|
|
||||||
(utils/current-sound-volume chorus-volume))
|
|
||||||
entities)
|
|
||||||
(assoc-in entities [:room :chorus :instance] (sound! (:sound chorus) :loop
|
|
||||||
(utils/current-sound-volume chorus-volume))))))))
|
|
||||||
:start-pos [245 90])))
|
:start-pos [245 90])))
|
||||||
|
|||||||
@@ -283,7 +283,9 @@
|
|||||||
|
|
||||||
(as-> entities entities
|
(as-> entities entities
|
||||||
(utils/play-sound! screen entities (get-in entities [:room :fountain-sound :sound])
|
(utils/play-sound! screen entities (get-in entities [:room :fountain-sound :sound])
|
||||||
:fountain 0.5 [172 120] :loop)
|
(utils/sourced-volume-fn :fountain 0.5 [172 120])
|
||||||
|
(utils/get-sound-pan 172)
|
||||||
|
:loop)
|
||||||
|
|
||||||
(if (= :night (get-in entities [:state :time]))
|
(if (= :night (get-in entities [:state :time]))
|
||||||
(make-night entities)
|
(make-night entities)
|
||||||
|
|||||||
@@ -805,9 +805,8 @@ void main()
|
|||||||
(if-let [[snd vol-scale] (get-in anim-sound-frames [anim current-frame-index])]
|
(if-let [[snd vol-scale] (get-in anim-sound-frames [anim current-frame-index])]
|
||||||
(utils/play-sound! screen entities
|
(utils/play-sound! screen entities
|
||||||
(or (snd e) (snd (:sounds entities)))
|
(or (snd e) (snd (:sounds entities)))
|
||||||
target
|
(utils/sourced-volume-fn target vol-scale [x y])
|
||||||
vol-scale
|
(utils/get-sound-pan x))
|
||||||
[x y])
|
|
||||||
entities)
|
entities)
|
||||||
entities))
|
entities))
|
||||||
|
|
||||||
@@ -822,10 +821,10 @@ void main()
|
|||||||
|
|
||||||
(defn update-current-sound-vols! [entities]
|
(defn update-current-sound-vols! [entities]
|
||||||
(loop [entities entities
|
(loop [entities entities
|
||||||
[{:keys [id sound duration loc vol-scale target loc]} & rest] (get-in entities [:current-sounds :value])]
|
[{:keys [id sound volume-fn]} & rest] (get-in entities [:current-sounds :value])]
|
||||||
(if id
|
(if id
|
||||||
(do
|
(do
|
||||||
(sound! sound :set-volume id (utils/get-sound-volume entities target vol-scale loc))
|
(sound! sound :set-volume id (volume-fn entities))
|
||||||
(recur entities rest))
|
(recur entities rest))
|
||||||
entities)))
|
entities)))
|
||||||
|
|
||||||
@@ -1027,6 +1026,8 @@ void main()
|
|||||||
(if (get-in entities [:closing? :value])
|
(if (get-in entities [:closing? :value])
|
||||||
|
|
||||||
(let [entities (utils/apply-tweens screen entities (:tweens entities))
|
(let [entities (utils/apply-tweens screen entities (:tweens entities))
|
||||||
|
entities (update-current-sound-vols! entities)
|
||||||
|
entities (remove-ended-sounds screen entities)
|
||||||
layers (get-layers entities)
|
layers (get-layers entities)
|
||||||
all-entities (concat (vals entities) layers (vals (get-in entities [:room :entities])))]
|
all-entities (concat (vals entities) layers (vals (get-in entities [:room :entities])))]
|
||||||
(screen! fade-screen :update-fade :opacity (get-in entities [:fade :opacity]))
|
(screen! fade-screen :update-fade :opacity (get-in entities [:fade :opacity]))
|
||||||
|
|||||||
@@ -256,9 +256,9 @@
|
|||||||
|
|
||||||
(defn load-sound [f]
|
(defn load-sound [f]
|
||||||
(try
|
(try
|
||||||
(sound (str f ".mp3"))
|
(sound f)
|
||||||
(catch Exception _
|
(catch Exception _
|
||||||
(sound f))))
|
(sound (str f ".mp3")))))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -402,36 +402,41 @@
|
|||||||
|
|
||||||
|
|
||||||
(defn get-sound-volume [entities target vol-scale [x y]]
|
(defn get-sound-volume [entities target vol-scale [x y]]
|
||||||
(if (= target :ego)
|
(* (if (= target :ego)
|
||||||
(-> (* (/ (get-in entities [:room :entities :ego :scale-x]) 1.5) 0.75)
|
(-> (* (/ (get-in entities [:room :entities :ego :scale-x]) 1.5) 0.75)
|
||||||
(* (or vol-scale 1.0))
|
(* (or vol-scale 1.0))
|
||||||
(clamp-volume))
|
(clamp-volume))
|
||||||
(proximity-volume entities [x y] :scale vol-scale)))
|
(proximity-volume entities [x y] :scale vol-scale))
|
||||||
|
(- 1.0 (get-in entities [:fade :opacity]))))
|
||||||
|
|
||||||
(defn get-sound-pan [x]
|
(defn get-sound-pan [x]
|
||||||
(/ (- x 160 ) 160))
|
(/ (- x 160 ) 160))
|
||||||
|
|
||||||
|
(defn sourced-volume-fn [target vol-scale [x y]]
|
||||||
|
(fn [entities]
|
||||||
|
(get-sound-volume entities target vol-scale [x y])))
|
||||||
|
|
||||||
|
|
||||||
(defn play-sound!
|
(defn play-sound!
|
||||||
([screen entities snd target vol-scale [x y]]
|
([screen entities snd volume-fn]
|
||||||
(play-sound! screen entities snd target vol-scale [x y] :once))
|
(play-sound! screen entities snd volume-fn 0.5))
|
||||||
|
|
||||||
([screen entities snd target vol-scale [x y] type]
|
([screen entities snd volume-fn pan]
|
||||||
(let [vol (get-sound-volume entities target vol-scale [x y])
|
(play-sound! screen entities snd volume-fn pan :once))
|
||||||
pan (get-sound-pan x)
|
|
||||||
|
([screen entities snd volume-fn pan type]
|
||||||
|
(let [vol (volume-fn entities)
|
||||||
sound-id (if (= :once type)
|
sound-id (if (= :once type)
|
||||||
(sound! snd :play (current-sound-volume vol) 1.0 pan)
|
(sound! snd :play (current-sound-volume vol) 1.0 pan)
|
||||||
(sound! snd :loop (current-sound-volume vol) 1.0 pan)) ]
|
(sound! snd :loop (current-sound-volume vol) 1.0 pan)) ]
|
||||||
(update-in entities [:current-sounds :value]
|
(update-in entities [:current-sounds :value]
|
||||||
conj {:id sound-id
|
conj {:id sound-id
|
||||||
:sound snd
|
:sound snd
|
||||||
:loc [x y]
|
:volume-fn volume-fn
|
||||||
:vol-scale vol-scale
|
|
||||||
:type type
|
:type type
|
||||||
:ends-at (if (= type :once)
|
:ends-at (if (= type :once)
|
||||||
(+ (:total-time screen) (sound! snd :duration))
|
(+ (:total-time screen) (sound! snd :duration))
|
||||||
nil)
|
nil)}))))
|
||||||
:target target}))))
|
|
||||||
|
|
||||||
(defn stop-all-sounds! [entities]
|
(defn stop-all-sounds! [entities]
|
||||||
(doseq [snd (get-in entities [:current-sounds :value])]
|
(doseq [snd (get-in entities [:current-sounds :value])]
|
||||||
|
|||||||
Reference in New Issue
Block a user