diff --git a/desktop/src-common/advent/actions.clj b/desktop/src-common/advent/actions.clj index 0d4aa266..f9b4e076 100644 --- a/desktop/src-common/advent/actions.clj +++ b/desktop/src-common/advent/actions.clj @@ -540,8 +540,7 @@ (defn give [entities item] (run-action entities (begin [this screen entities] - (sound! (utils/load-sound "pickup.ogg") :play (utils/current-sound-volume 0.3)) - + (utils/play-sound! screen entities :pickup (constantly 0.3)) (-> entities (update-in [:state :inventory] #(conj % item)) (update-in [:state :obtained-items] #(conj % item)) diff --git a/desktop/src-common/advent/screens/rooms/cat_tree.clj b/desktop/src-common/advent/screens/rooms/cat_tree.clj index cc42c4b9..2ea3f70c 100644 --- a/desktop/src-common/advent/screens/rooms/cat_tree.clj +++ b/desktop/src-common/advent/screens/rooms/cat_tree.clj @@ -230,6 +230,8 @@ owl-puke (utils/make-anim "cat-tree/owl.png" [21 30] 0.10 [0 0 2 2 3 2 2 3 3 2 3 3 3 4 5 6 7 4 4 3 3 2 2 2 2 2]) puke (particle-effect "particles/puke")] (rooms/make :music {:day :town-2 :night :night} + :sounds {:cat (utils/load-sound "cat-tree/cat.ogg") + :kiss (utils/load-sound "cat-tree/kiss.ogg")} :ladder ladder-entity :blank (rooms/make-entity :blank {:object nil :x 0 :y 0 :width 320 :height 240 :baseline 240 @@ -316,7 +318,7 @@ (if (get-in @entities [:room :entities :ladder]) (do (actions/talk entities :ego "I think he's going for it!") (actions/play-animation entities :ego :cat-toy-first-half :stop? false) - (sound! (utils/load-sound "cat-tree/cat.ogg") :play (utils/current-sound-volume)) + (actions/play-sound entities :cat 0.5) (actions/walk-straight-to entities :cat [138 40] :update-baseline? false :speed 3) (actions/play-animation entities :ego :cat-toy-last-half) (actions/play-animation entities :grandma :squat-1 :stop? false) @@ -331,7 +333,7 @@ :grandma "Come here young man.") (actions/walk-straight-to entities :ego [133 35]) (actions/talk entities :grandma "For your impressive display of courage and bravery, I give you this. ") - (sound! (utils/load-sound "cat-tree/kiss.ogg") :play (utils/current-sound-volume)) + (actions/play-sound entities :kiss 0.7) (actions/play-animation entities :grandma :kiss) (actions/play-animation entities :ego :get-sick :stop? false) (actions/walk-straight-to entities :ego [165 45]) diff --git a/desktop/src-common/advent/screens/rooms/common.clj b/desktop/src-common/advent/screens/rooms/common.clj index 9c07f5c9..b788fa63 100644 --- a/desktop/src-common/advent/screens/rooms/common.clj +++ b/desktop/src-common/advent/screens/rooms/common.clj @@ -33,6 +33,7 @@ wizard-talk-angry (utils/make-anim "wizard/talk-angry.png" [20 50] 0.2 [0 2 0 2 1 2 0 3 0 2 0 1 0 2]) wizard-magic-hands (utils/make-anim "wizard/magic-hands.png" [20 50] 0.2 (range 2)) wizard-disappear (utils/make-anim "wizard/disappear.png" [20 46] 0.075 (range 19)) + disappear-left (utils/flip wizard-disappear) wizard-talk (animation 0.2 (for [i [0 2 0 2 1 2 0 3 0 2 0 1 0 2]] (aget wizard-sheet 0 i))) wizard-talk-left (utils/flip wizard-talk) @@ -41,7 +42,7 @@ (actions/start-animation screen (merge (assoc (animation->texture screen wizard-stand) :left {:talk wizard-talk-left :stand wizard-stand-left - :disappear (utils/flip wizard-disappear) + :disappear disappear-left :magic-hands (utils/flip wizard-magic-hands) :talk-angry wizard-talk-angry-left } @@ -59,7 +60,10 @@ wizard-talk-left {11 [:blink 0.15 0.7] 4 [:blink 0.15 0.7]} wizard-talk-angry-left {11 [:blink 0.15 0.7] - 4 [:blink 0.15 0.7]}} + 4 [:blink 0.15 0.7]} + wizard-disappear {1 [:disappear 0.7]} + disappear-left {1 [:disappear 0.7]} + } :night-profile :sprite :origin-x 0 :origin-y 0 diff --git a/desktop/src-common/advent/screens/rooms/inside_antique.clj b/desktop/src-common/advent/screens/rooms/inside_antique.clj index 5cb050af..5356b9fe 100644 --- a/desktop/src-common/advent/screens/rooms/inside_antique.clj +++ b/desktop/src-common/advent/screens/rooms/inside_antique.clj @@ -187,6 +187,10 @@ :shopkeep "That teddy bear does not leave my store." :shopkeep "My son would be stricken with grief to find it missing."))))] (rooms/make :music :inside-antique + :sounds {:fire-1 (utils/load-sound "inside-antique/fire-1.ogg") + :fire-2 (utils/load-sound "inside-antique/fire-2.ogg") + :fire-3 (utils/load-sound "inside-antique/fire-3.ogg") + } :interactions {:right {:box [250 0 320 75] :cursor :right @@ -339,7 +343,8 @@ (actions/talk entities :ego "I'll just try another one of these mints.")) (actions/play-animation entities :ego :reach) (actions/update-state entities (fn [s] (assoc s :mints-eaten (inc (s :mints-eaten))))) - (sound! (utils/load-sound (str "inside-antique/fire-" (get-in @entities [:state :mints-eaten]) ".ogg")) :play (utils/current-sound-volume)) + (actions/play-sound entities (keyword (str "fire-" (get-in @entities [:state :mints-eaten]))) 0.8) + (cond (= 2 (get-in @entities [:state :mints-eaten])) (do (particle-effect! (get-in @entities [:room :entities :smoke-particle]) :reset) diff --git a/desktop/src-common/advent/screens/rooms/inside_cafeteria.clj b/desktop/src-common/advent/screens/rooms/inside_cafeteria.clj index 381922c4..6963c380 100644 --- a/desktop/src-common/advent/screens/rooms/inside_cafeteria.clj +++ b/desktop/src-common/advent/screens/rooms/inside_cafeteria.clj @@ -74,7 +74,6 @@ (if (actions/has-item? @entities :flask-1-strength) (do (actions/do-dialogue entities :ego "One sec.") - (sound! (utils/load-sound "ego/potion.ogg") :play (utils/current-sound-volume)) (actions/play-animation entities :ego :grow :stop? false) (play-battle entities :win) (actions/do-dialogue entities diff --git a/desktop/src-common/advent/screens/rooms/inside_castle.clj b/desktop/src-common/advent/screens/rooms/inside_castle.clj index f571c892..46a3418d 100644 --- a/desktop/src-common/advent/screens/rooms/inside_castle.clj +++ b/desktop/src-common/advent/screens/rooms/inside_castle.clj @@ -55,7 +55,7 @@ (begin [this screen entities] (particle-effect! (get-in entities [:room :entities :appear]) :reset) (particle-effect! (get-in entities [:room :entities :appear]) :start) - (sound! (utils/load-sound "inside-house/disappear.ogg") :play (utils/current-sound-volume)) + (utils/play-sound! screen entities :disappear (constantly 0.7)) (-> entities (assoc-in [:tweens :bloodclot-head-appear] (tween/tween :bloodclot-head-appear screen [:room :entities :bloodclot-head :opacity] 0.0 1.0 1.0 :ease tween/ease-in-quadratic)) @@ -209,7 +209,6 @@ :game-player "But I'm not much of a hero." :game-player "The knights of Remington have muscles the size of tree trunks." :game-player "But me...") - (sound! (utils/load-sound "inside-castle/flex.ogg") :play (utils/current-sound-volume)) (actions/play-animation entities :game-player :flex) (actions/do-dialogue entities :game-player "I'd never be able to prove my strength.")) :choices actions/previous-choices} @@ -613,12 +612,14 @@ :talk game-player-talk-up} :get-to-work game-player-get-to-work :pause-from-work game-player-pause-from-work + :flex-sound (utils/load-sound "inside-castle/flex.ogg") :anim-sound-frames {game-player-stand-up {11 [:blink 0.3 1.1] } game-player-talk-up {11 [:blink 0.3 1.1] 22 [:blink 0.3 1.1] 24 [:blink 0.3 1.1] 27 [:blink 0.3 1.1]} - game-player-stand-down {1 [:writing-sound 0.07]}} + game-player-stand-down {1 [:writing-sound 0.07]} + game-player-flex {1 [:flex-sound 0.5]}} :flex game-player-flex)} :monocle (rooms/make-entity :monocle (assoc (animation->texture screen monocle) :x 209 :y 160 :baseline 240 diff --git a/desktop/src-common/advent/screens/rooms/inside_house.clj b/desktop/src-common/advent/screens/rooms/inside_house.clj index c875a1f7..b804e8f2 100644 --- a/desktop/src-common/advent/screens/rooms/inside_house.clj +++ b/desktop/src-common/advent/screens/rooms/inside_house.clj @@ -123,7 +123,6 @@ :wizard "Ok, I'll deliver some more myself. Don't touch anything while I'm gone.") (actions/update-state entities (fn [s] (assoc s :mints-eaten 0 :wizard-left? true))) - (sound! (utils/load-sound "inside-house/disappear.ogg") :play (utils/current-sound-volume)) (actions/play-animation entities :wizard :disappear :stop? false) (actions/remove-entity entities :wizard))} "Nevermind." diff --git a/desktop/src-common/advent/screens/rooms/inside_jail.clj b/desktop/src-common/advent/screens/rooms/inside_jail.clj index 9095782b..320249cf 100644 --- a/desktop/src-common/advent/screens/rooms/inside_jail.clj +++ b/desktop/src-common/advent/screens/rooms/inside_jail.clj @@ -225,6 +225,9 @@ candle (utils/make-anim "inside-jail/candle.png" [20 25] 0.1 (range 4)) candle-aura (utils/make-anim "inside-house/candle-aura.png" [27 27] 0.2 [0 1 2 3 2 1])] (rooms/make :music :inside-antique + :sounds { + :squeek (utils/load-sound "inside-jail/squeak.ogg") + } :interactions { :lock {:box [172 102 190 124] :script (actions/get-script entities @@ -332,7 +335,7 @@ (update-in [:room :entities :ego] #(actions/start-animation screen % :stand)))] ((actions/get-script entities (actions/stop-walking entities :ego) - (actions/play-sound entities "inside-jail/squeak.ogg" 0.15) + (actions/play-sound entities :squeek 0.15) (actions/do-dialogue entities :ego "Oops!" :warden "Hey! What are you doing?" diff --git a/desktop/src-common/advent/screens/rooms/space.clj b/desktop/src-common/advent/screens/rooms/space.clj index 8d818357..4a77be4d 100644 --- a/desktop/src-common/advent/screens/rooms/space.clj +++ b/desktop/src-common/advent/screens/rooms/space.clj @@ -35,13 +35,13 @@ (not (get-in entities [:state :blergh-dead?])) (actions/has-item? entities :magic-slingshot)) ((actions/get-script entities - (sound! (utils/load-sound "space/shock.ogg") :play (utils/current-sound-volume)) - (actions/play-animation entities :bloodclot-head :shoot :stop? false) - (actions/update-entity entities :lightning #(assoc % :opacity 1.0)) - (actions/begin-animation entities :bloodclot-head :keep-shoot) - (Thread/sleep 2000) - (actions/update-entity entities :lightning #(assoc % :opacity 0.0)) - (actions/do-dialogue entities :bloodclot-head "Dang! Come a little closer!")) + (actions/play-sound entities :shock 0.25 :wait? false) + (actions/play-animation entities :bloodclot-head :shoot :stop? false) + (actions/update-entity entities :lightning #(assoc % :opacity 1.0)) + (actions/begin-animation entities :bloodclot-head :keep-shoot) + (Thread/sleep 2000) + (actions/update-entity entities :lightning #(assoc % :opacity 0.0)) + (actions/do-dialogue entities :bloodclot-head "Dang! Come a little closer!")) entities)) nil) @@ -62,7 +62,7 @@ (begin [this screen entities] (particle-effect! (get-in entities [:room :entities :appear]) :reset) (particle-effect! (get-in entities [:room :entities :appear]) :start) - (sound! (utils/load-sound "inside-house/disappear.ogg") :play (utils/current-sound-volume)) + (utils/play-sound! screen entities :disappear (constantly 0.7)) (-> entities (assoc-in [:tweens :bloodclot-head-appear] (tween/tween :bloodclot-head-appear screen [:room :entities :bloodclot-head :opacity] 1.0 0.0 1.0 :ease tween/ease-in-cubic)) @@ -91,7 +91,8 @@ (actions/run-action entities (begin [this screen entities] - (sound! (utils/load-sound "space/jump.ogg") :play (utils/current-sound-volume)) + (utils/play-sound! screen entities :jump (constantly 0.9)) + (-> entities (assoc-in [:room :entities :cloud] (assoc (utils/get-texture "space/cloud.png") :x (- (get-in entities [:room :entities :ego :x]) 10) @@ -138,7 +139,8 @@ (actions/run-action entities (begin [this screen entities] - (sound! (utils/load-sound "space/swingsword.ogg") :play (utils/current-sound-volume)) + (utils/play-sound! screen entities :swing-sword (constantly 0.9)) + (-> entities (update-in [:room :entities :ego] #(actions/start-animation screen % :swing)) @@ -191,6 +193,9 @@ lightning-effect (particle-effect "particles/lightning") grow-explode (particle-effect "particles/grow-explode")] (rooms/make :music :fight + :sounds {:shock (utils/load-sound "space/shock.ogg") + :jump (utils/load-sound "space/jump.ogg") + :swing-sword (utils/load-sound "space/swingsword.ogg")} :interactions {} :layers [(assoc (utils/get-texture "space/background.png") :x 0 :y 0 :baseline 0)] @@ -255,7 +260,8 @@ (actions/do-dialogue entities :bloodclot-head "Ha ha ha! Is that the best you can do?" :bloodclot-head "Take this!") - (sound! (utils/load-sound "space/shock.ogg") :play (utils/current-sound-volume)) + (actions/play-sound entities :shock 0.25 :wait? false) + (actions/play-animation entities :bloodclot-head :shoot :stop? false) (actions/begin-animation entities :bloodclot-head :keep-shoot) (actions/update-entity entities :lightning #(assoc % :opacity 1.0)) diff --git a/desktop/src-common/advent/screens/scene.clj b/desktop/src-common/advent/screens/scene.clj index ffdafa00..919033b4 100644 --- a/desktop/src-common/advent/screens/scene.clj +++ b/desktop/src-common/advent/screens/scene.clj @@ -267,7 +267,6 @@ void main () (get-in @entities [:room :entities :warden]) (do (actions/talk entities :ego "I'll just take a sip!") - (sound! (utils/load-sound "ego/potion.ogg") :play (utils/current-sound-volume)) (actions/play-animation entities :ego :grow :stop? false) (actions/talk entities :warden "Huh? What was that?!") (Thread/sleep 1000) @@ -277,7 +276,6 @@ void main () :else (do (actions/talk entities :ego "I'll just take a sip!") - (sound! (utils/load-sound "ego/potion.ogg") :play (utils/current-sound-volume)) (actions/play-animation entities :ego :grow :stop? false)))) :recipe @@ -664,10 +662,10 @@ void main () :inside-step-sound-2 (utils/load-sound "ego/inside-step-2.ogg") :inside-step-sound-3 (utils/load-sound "ego/inside-step-3.ogg") :inside-step-sound-4 (utils/load-sound "ego/inside-step-4.ogg") + :grow-sound (utils/load-sound "ego/potion.ogg") :sigh-sound (utils/load-sound "ego/sigh.ogg") :breakglass-sound (utils/load-sound "ego/breakglass.ogg") :idea-sound (utils/load-sound "ego/idea.ogg") - :blink (utils/load-sound "ego/blink2.ogg") :scale-x start-scale :scale-y start-scale :talk-color (color 0.6 1.0 1.0 1.0) @@ -682,13 +680,15 @@ void main () :x (first start-pos) :y (last start-pos) :id "ego"} - ego (assoc ego :anim-sound-frames {(get-in ego [:left :walk]) {2 [choose-step-sound 0.3] - 6 [choose-step-sound 0.3]} - (get-in ego [:right :walk]) {2 [choose-step-sound 0.3] - 6 [choose-step-sound 0.3]} + ego (assoc ego :anim-sound-frames {(get-in ego [:left :walk]) {2 [choose-step-sound 0.5] + 6 [choose-step-sound 0.5]} + (get-in ego [:right :walk]) {2 [choose-step-sound 0.5] + 6 [choose-step-sound 0.5]} (get-in ego [:left :talk] ) {2 [:blink 0.15]} (get-in ego [:right :talk] ) {2 [:blink 0.15]} + (get-in ego [:left :grow] ) {1 [:grow-sound 0.5]} + (get-in ego [:right :grow] ) {1 [:grow-sound 0.5]} (get-in ego [:left :stand]) {11 [:blink 0.15] 44 [:blink 0.15] @@ -850,7 +850,7 @@ void main () (snd entities) snd)] (utils/play-sound! screen entities - (or (snd e) (snd (:sounds entities))) + (or (snd e) snd) (utils/sourced-volume-fn target vol-scale [x y]) (utils/get-sound-pan x) :once @@ -872,7 +872,7 @@ void main () [{:keys [id sound volume-fn]} & rest] (get-in entities [:current-sounds :value])] (if id (do - (sound! sound :set-volume id (utils/scale-vol-from-fade entities (volume-fn entities))) + (sound! sound :set-volume id (utils/scale-vol-from-fade entities (utils/current-sound-volume (volume-fn entities)))) (recur entities rest)) entities))) @@ -1047,6 +1047,8 @@ void main () :closing? {:object nil :value false} :sounds {:blink (utils/load-sound "ego/blink2.ogg") + :pickup (utils/load-sound "pickup.ogg") + :disappear (utils/load-sound "inside-house/disappear.ogg") :object nil} :fade {:object nil :opacity 0.0} diff --git a/desktop/src-common/advent/utils.clj b/desktop/src-common/advent/utils.clj index 885ed0f7..38cad44f 100644 --- a/desktop/src-common/advent/utils.clj +++ b/desktop/src-common/advent/utils.clj @@ -445,6 +445,10 @@ ([screen entities snd volume-fn pan type pitch] (let [vol (volume-fn entities) + snd (if (keyword? snd) + (or (-> entities :room :sounds snd) + (-> entities :sounds snd)) + snd) sound-id (if (= :once type) (sound! snd :play (scale-vol-from-fade entities (current-sound-volume vol)) (or pitch 1.0) pan ) (sound! snd :loop (scale-vol-from-fade entities (current-sound-volume vol)) (or pitch 1.0) pan )) ]