From 7857c8cf0901eaa0760a987438595d54d96fb407 Mon Sep 17 00:00:00 2001 From: Bryce Covert Date: Wed, 21 Jun 2017 20:07:57 -0700 Subject: [PATCH] fixed music up. --- desktop/src-common/advent/actions.clj | 8 ++++---- .../advent/screens/rooms/behind_house.clj | 3 +-- .../advent/screens/rooms/castle_gate.clj | 2 +- .../advent/screens/rooms/cat_tree.clj | 3 +-- .../src-common/advent/screens/rooms/dream.clj | 2 +- .../advent/screens/rooms/ending.clj | 2 +- .../src-common/advent/screens/rooms/held.clj | 3 +-- .../advent/screens/rooms/inside_antique.clj | 2 +- .../advent/screens/rooms/inside_cafeteria.clj | 3 +-- .../advent/screens/rooms/inside_castle.clj | 3 +-- .../advent/screens/rooms/inside_house.clj | 2 +- .../advent/screens/rooms/inside_jail.clj | 3 +-- .../advent/screens/rooms/inside_stash.clj | 2 +- .../advent/screens/rooms/outside_castle.clj | 3 +-- .../advent/screens/rooms/outside_house.clj | 3 +-- .../advent/screens/rooms/outside_jail.clj | 2 +- .../src-common/advent/screens/rooms/space.clj | 3 +-- desktop/src-common/advent/screens/scene.clj | 19 ++++++++++++++++++- desktop/src-common/advent/utils.clj | 4 ++-- 19 files changed, 40 insertions(+), 32 deletions(-) diff --git a/desktop/src-common/advent/actions.clj b/desktop/src-common/advent/actions.clj index 8bfebb7c..4a596d9f 100644 --- a/desktop/src-common/advent/actions.clj +++ b/desktop/src-common/advent/actions.clj @@ -676,9 +676,10 @@ (defn transition-background [entities new-background [x y] & {:keys [transition-music? between time face]}] (let [transition-music? (if (nil? transition-music?) true transition-music?) - old-music (get-music (get-in @entities [:room :music]) (get-in @entities [:state :time])) + old-music (get-music (get-in @entities [:room-musics (get-in @entities [:state :last-room])]) (get-in @entities [:state :time])) ;; TODO FIX - new-music old-music + new-music (get-music (get-in @entities [:room-musics new-background]) (get-in @entities [:state :time])) + _ (println old-music new-music) music-changed? (and transition-music? (not= old-music new-music)) time (/ (float (or time 1.0)) 2.0)] (run-action entities @@ -720,7 +721,7 @@ (begin [this screen entities] (utils/stop-all-sounds! entities) (let [ego (get-in entities [:room :entities :ego]) - old-music (get-music (get-in entities [:room :music]) (get-in entities [:state :time])) + entities (as-> entities e (assoc-in e [:room] ((get-in entities [:rooms new-background]) screen)) (assoc-in e [:room :entities :ego] ego) @@ -740,7 +741,6 @@ (if music-changed? (assoc-in e [:tweens :fade-in-music] (tween/tween :fade-in-music screen [:volume :value] 0.0 1.0 time)) e)) - new-music (get-music (get-in entities [:room :music]) (get-in entities [:state :time])) apply-state (get-in entities [:room :apply-state]) entities (if apply-state (apply-state screen entities) diff --git a/desktop/src-common/advent/screens/rooms/behind_house.clj b/desktop/src-common/advent/screens/rooms/behind_house.clj index 2d4bded5..20b12dff 100644 --- a/desktop/src-common/advent/screens/rooms/behind_house.clj +++ b/desktop/src-common/advent/screens/rooms/behind_house.clj @@ -30,8 +30,7 @@ (fn [state] (assoc state :safe-listen-count (inc (:safe-listen-count state 0)))))) (defn make [screen atlas global-atlas] - (rooms/make :music {:day :town-2 :night :night} - :name "Behind house" + (rooms/make :name "Behind house" :interactions {:left-dir-1 (make-left-dir [0 48 20 240]) :left-dir-2 (make-left-dir [0 160 148 217]) diff --git a/desktop/src-common/advent/screens/rooms/castle_gate.clj b/desktop/src-common/advent/screens/rooms/castle_gate.clj index 1fc61829..2dac2f80 100644 --- a/desktop/src-common/advent/screens/rooms/castle_gate.clj +++ b/desktop/src-common/advent/screens/rooms/castle_gate.clj @@ -202,7 +202,7 @@ (let [throw-walkie (utils/make-anim-seq atlas "throw-walkie" [205 136] 0.1 (flatten [(repeat 55 0) (range 9) (repeat 55 8)])) walkie-visible (animation 1.0 [(utils/atlas->texture atlas "throw-walkie" 8)]) walkie-invisible (animation 1.0 [(utils/atlas->texture atlas "throw-walkie" 0)])] - (rooms/make :music {:day :town-2 :night :night} + (rooms/make :name "Castle gate" :timers {:taunt [1.0 6.0 flip-coin]} :interactions {:right-dir {:box [280 40 320 83] diff --git a/desktop/src-common/advent/screens/rooms/cat_tree.clj b/desktop/src-common/advent/screens/rooms/cat_tree.clj index 7f577a3f..f592e781 100644 --- a/desktop/src-common/advent/screens/rooms/cat_tree.clj +++ b/desktop/src-common/advent/screens/rooms/cat_tree.clj @@ -267,8 +267,7 @@ owl-puke (utils/make-anim atlas "owl" [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]) owl-eye (utils/make-anim-seq atlas "eye" [44 48] 0.10 [0 0 1 1 2 2 2 2 2 2 2 1 1 3 3 3 3 3 3 3 3 3 3 3 3 3 4 4 3 4 4 4 3 4 4 4 5 6 7 8 9 9 9 9 9 9 9 9 9 10 11 12 12 11 10 9 9 9 9 9 9 9 9 10 11 12 12 12 11 10 9 9 9 9 9 8 7 6 5]) puke (particle-effect "particles/puke")] - (rooms/make :music {:day :town-2 :night :night} - :name "Tree" + (rooms/make :name "Tree" :sounds {:cat (utils/load-sound "cat-tree/cat.ogg") :kiss (utils/load-sound "cat-tree/kiss.ogg")} :ladder ladder-entity diff --git a/desktop/src-common/advent/screens/rooms/dream.clj b/desktop/src-common/advent/screens/rooms/dream.clj index 4ff6f24d..af1404b8 100644 --- a/desktop/src-common/advent/screens/rooms/dream.clj +++ b/desktop/src-common/advent/screens/rooms/dream.clj @@ -371,7 +371,7 @@ (let [fairy-godfather-anim (utils/make-anim atlas "fairy-godfather" [63 77] 0.15 [0 1 2 3 2 1 0 1 4 3 2 1]) fairy-godfather-talk-anim (utils/make-anim atlas "fairy-godfather" [63 77] 0.15 [5 6 7 8 7 6]) fairy-godfather-magic-anim (utils/make-anim atlas "fairy-godfather-magic" [100 77] 0.15 [0 1 2 3 4 4 4 4 3 2 1 0])] - (rooms/make :music {:intro :wind :day :dream} + (rooms/make :name "Dream" :interactions {:pit {:box [54 0 219 36] :label "Pit of destiny" diff --git a/desktop/src-common/advent/screens/rooms/ending.clj b/desktop/src-common/advent/screens/rooms/ending.clj index 4f1431eb..95310d33 100644 --- a/desktop/src-common/advent/screens/rooms/ending.clj +++ b/desktop/src-common/advent/screens/rooms/ending.clj @@ -46,7 +46,7 @@ frankie-fall (utils/make-anim-seq atlas "frankie-fall" [40 35] 0.1 (flatten [(range 8) (repeat 20 7) 8 9 10 11 7])) frankie-down (utils/make-anim-seq atlas "frankie-fall" [40 35] 0.1 [0]) scaler (utils/scaler-fn-with-baseline 20 1.3 1.30)] - (rooms/make :music :dream + (rooms/make :sounds {:cloud (utils/load-sound "ending-castle/cloud.ogg")} :name "Ending" :interactions {} diff --git a/desktop/src-common/advent/screens/rooms/held.clj b/desktop/src-common/advent/screens/rooms/held.clj index 18d00493..2e6f4256 100644 --- a/desktop/src-common/advent/screens/rooms/held.clj +++ b/desktop/src-common/advent/screens/rooms/held.clj @@ -60,8 +60,7 @@ (defn make [screen atlas global-atlas] (let [bloodclot-talk (utils/make-anim-seq atlas "bloodclot-head" [114 82] 0.1 [0 1 2 1 0 3 3 0 1 2 1 0 3 4 5 6 5 3 3 1 2 1 3 3 3 3 3 0 0 0 7 8 7]) bloodclot-stand (utils/make-anim-seq atlas "bloodclot-head" [114 82] 0.1 (flatten [(repeat 15 0) 7 8 7]))] - (rooms/make :music :fight - :name "Held" + (rooms/make :name "Held" :interactions {:bloodclot {:box [182 42 270 196] :label "Bloodclot" :cursor :talk diff --git a/desktop/src-common/advent/screens/rooms/inside_antique.clj b/desktop/src-common/advent/screens/rooms/inside_antique.clj index 8121bacf..f06ad8c7 100644 --- a/desktop/src-common/advent/screens/rooms/inside_antique.clj +++ b/desktop/src-common/advent/screens/rooms/inside_antique.clj @@ -224,7 +224,7 @@ :shopkeep "Don't get any fast ideas." :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 + (rooms/make :name "Antique shop" :sounds {:fire-1 (utils/load-sound "inside-antique/fire-1.ogg") :fire-2 (utils/load-sound "inside-antique/fire-2.ogg") diff --git a/desktop/src-common/advent/screens/rooms/inside_cafeteria.clj b/desktop/src-common/advent/screens/rooms/inside_cafeteria.clj index 34244818..4b79b753 100644 --- a/desktop/src-common/advent/screens/rooms/inside_cafeteria.clj +++ b/desktop/src-common/advent/screens/rooms/inside_cafeteria.clj @@ -198,8 +198,7 @@ (pace [0 0 0 0 2 1 1 2 2 1 1 2 2 2 1 1 2 2 2 2 2 2 2 2 2 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3] 0)])) hands-fight-lose (utils/make-anim-seq atlas "fight-new-assets/fight" [256 192] 0.1 (flatten [4 4 4 4 4 4 0 0 0 0 4 4 4 0 0 0 5 5 5 6 6 6 6 6 6]))] - (rooms/make :music :town-1 - :name "Cafeteria" + (rooms/make :name "Cafeteria" :interactions {:right-dir {:box [272 45 320 120] :only-script (actions/get-script diff --git a/desktop/src-common/advent/screens/rooms/inside_castle.clj b/desktop/src-common/advent/screens/rooms/inside_castle.clj index 62017041..4052f1b1 100644 --- a/desktop/src-common/advent/screens/rooms/inside_castle.clj +++ b/desktop/src-common/advent/screens/rooms/inside_castle.clj @@ -380,8 +380,7 @@ monocle (utils/make-anim atlas "monocle" [19 19] 0.05 (flatten [(repeat 70 0) 1 2 3 3 3 2 1])) door (utils/make-anim atlas "door" [21 49] 0.15 (flatten [(range 4) 3 3 3 3 3 3 3])) ] - (rooms/make :music {:day :town-1 :night :night :sunrise :night} - :name "Inside castle" + (rooms/make :name "Inside castle" :timers {:brian [10.0 7.0 brian]} :interactions {:right-door {:box [286 140 306 160] diff --git a/desktop/src-common/advent/screens/rooms/inside_house.clj b/desktop/src-common/advent/screens/rooms/inside_house.clj index 9374987f..ee2826d1 100644 --- a/desktop/src-common/advent/screens/rooms/inside_house.clj +++ b/desktop/src-common/advent/screens/rooms/inside_house.clj @@ -138,7 +138,7 @@ candle (utils/make-anim atlas "candle" [34 32] 0.2 [1 0 1 2]) candle-aura (utils/make-anim atlas "candle-aura" [27 27] 0.2 [0 1 2 3 2 1] ) experiment-left (utils/flip (utils/make-anim-seq global-atlas "wizard/experiment" [45 55] 0.075 [0 0 0 0 0 0 0 0 0 0 1 1 2 2 2 2 3 3 3 4 4 5 5 6 6 6 6 6 6 7 8 9 9 10 10 11 11 12 12 12 12 12 12 12 12 12 12 12 13 13 14 14 14 14 14 15 15 16 16 17 17 18 18 18 18 19 20 21 21 21 21 21 21 22 23 22 23 22 23 22 23 23 23 23 23 23 23 23 24 24 24 24 24 24 24 24 24 25 26 27 37 38 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 29 29 29 28 28 28 28 29 29 28 28 28 28 28 28 28 28 30 30 30 30 31 32 33 31 31 31 31 31 31 31 31 34 35 36 36 36 36 36 36 36 36 36] ))] - (rooms/make :music :inside-fangald + (rooms/make :name "Inside house" :interactions {:down-dir {:box [151 0 320 40] :only-script (actions/get-script entities diff --git a/desktop/src-common/advent/screens/rooms/inside_jail.clj b/desktop/src-common/advent/screens/rooms/inside_jail.clj index 447c2503..f1d3c239 100644 --- a/desktop/src-common/advent/screens/rooms/inside_jail.clj +++ b/desktop/src-common/advent/screens/rooms/inside_jail.clj @@ -230,8 +230,7 @@ candle (utils/make-anim atlas "candle" [20 25] 0.1 (range 4)) candle-aura (utils/make-anim atlas "candle-aura" [27 27] 0.2 [0 1 2 3 2 1]) crowbar (utils/make-anim atlas "crowbar" [16 33] 0.15 (flatten [(repeat 120 0) [1 2 3 3 2 1]]))] - (rooms/make :music :inside-antique - :name "In jail" + (rooms/make :name "In jail" :sounds { :squeek (utils/load-sound "inside-jail/squeak.ogg") :crowbar-sound (utils/load-sound "ego/crowbar.ogg") diff --git a/desktop/src-common/advent/screens/rooms/inside_stash.clj b/desktop/src-common/advent/screens/rooms/inside_stash.clj index fce41025..1ce2d798 100644 --- a/desktop/src-common/advent/screens/rooms/inside_stash.clj +++ b/desktop/src-common/advent/screens/rooms/inside_stash.clj @@ -60,7 +60,7 @@ candle-flame (utils/make-anim atlas "candle" [4 4] 0.1 (range 4)) candle-aura (utils/make-anim atlas "candle-aura" [27 27] 0.2 [0 1 2 3 2 1] ) ] - (rooms/make :music {:day :secret-hideout :night :secret-hideout} + (rooms/make :name "Inside stash" :interactions {:left-dir {:box [91 60 125 140] diff --git a/desktop/src-common/advent/screens/rooms/outside_castle.clj b/desktop/src-common/advent/screens/rooms/outside_castle.clj index 296d8c6d..88352bf8 100644 --- a/desktop/src-common/advent/screens/rooms/outside_castle.clj +++ b/desktop/src-common/advent/screens/rooms/outside_castle.clj @@ -341,8 +341,7 @@ steer-stand (animation 0.2 (for [i [0 0 0 0 0 0 0 0 0 1 0 2 0 1 0 2 0 1 0 2 0 0 0 0 0 0 0 0 0 0 0 0 0 3 3 3 3 3 3 3 3 3 0 0 0 0]] (aget steer-sheet 0 i))) flies-stand (utils/make-anim atlas "flies" [21 21] 0.075 (flatten (repeat 2 [0 1 2 1])))] - (rooms/make :music {:day :town-2 :night :night :sunrise :night} - :name "Outside castle" + (rooms/make :name "Outside castle" :interactions {:right-dir {:box [280 40 320 140] :only-script (actions/get-script diff --git a/desktop/src-common/advent/screens/rooms/outside_house.clj b/desktop/src-common/advent/screens/rooms/outside_house.clj index bcfb1ddd..426cf033 100644 --- a/desktop/src-common/advent/screens/rooms/outside_house.clj +++ b/desktop/src-common/advent/screens/rooms/outside_house.clj @@ -623,8 +623,7 @@ lamb-stand (aget lamb-walk-sheet 0 0) lamb-walk (animation 0.075 (for [i (range 4)] (aget lamb-walk-sheet 0 i)))] - (rooms/make :music {:day :town-2 :night :night} - :name "Outside house" + (rooms/make :name "Outside house" :update-fn jump-around :cauldron-sound {:object nil :sound (utils/load-sound "outsidehouse/cauldron.ogg")} :interactions diff --git a/desktop/src-common/advent/screens/rooms/outside_jail.clj b/desktop/src-common/advent/screens/rooms/outside_jail.clj index 4dddfb6e..eaf3475a 100644 --- a/desktop/src-common/advent/screens/rooms/outside_jail.clj +++ b/desktop/src-common/advent/screens/rooms/outside_jail.clj @@ -103,7 +103,7 @@ close-stash (utils/make-anim atlas "open-stash" [58 41] 0.075 (range 5)) candle-flame (utils/make-anim atlas "candle" [20 25] 0.075 (range 4)) candle-aura (utils/make-anim atlas "candle-aura2" [135 135] 0.3 [0 1 2 1] )] - (rooms/make :music {:day :town-1 :night :night} + (rooms/make :name "Fountain" :interactions {:down-dir {:box [30 0 227 40] :only-script (actions/get-script entities diff --git a/desktop/src-common/advent/screens/rooms/space.clj b/desktop/src-common/advent/screens/rooms/space.clj index f7905862..d5a1b941 100644 --- a/desktop/src-common/advent/screens/rooms/space.clj +++ b/desktop/src-common/advent/screens/rooms/space.clj @@ -195,8 +195,7 @@ blowup-effect (particle-effect "particles/blowup") lightning-effect (particle-effect "particles/lightning") grow-explode (particle-effect "particles/grow-explode")] - (rooms/make :music :fight - :name "Duel" + (rooms/make :name "Duel" :sounds {:shock (utils/load-sound "space/shock.ogg") :shock-short (utils/load-sound "space/shock-short.ogg") :jump (utils/load-sound "space/jump.ogg") diff --git a/desktop/src-common/advent/screens/scene.clj b/desktop/src-common/advent/screens/scene.clj index c4704879..fd8f3ff9 100644 --- a/desktop/src-common/advent/screens/scene.clj +++ b/desktop/src-common/advent/screens/scene.clj @@ -897,7 +897,7 @@ (defn fade-in-first-time-if-necessary [screen entities] (if (not (get-in entities [:started? :value])) (do (music! (utils/get-current-music entities) :set-volume (utils/current-music-volume (get-in entities [:volume :value]))) - (utils/play-music (get-in entities [:musics (actions/get-music (get-in entities [:room :music]) (get-in entities [:state :time]))])) + (utils/play-music (get-in entities [:musics (actions/get-music (get-in entities [:room-musics (doto (get-in entities [:state :last-room]) println)]) (get-in entities [:state :time]))])) (-> entities (assoc :tweens {:fade-in (tween/tween :fade-in screen [:fade :opacity] 1.0 0.0 1.0 :ease tween/ease-in-cubic @@ -1223,7 +1223,24 @@ :castle-gate (wrap rooms.castle-gate/make "packed/castle-gate.atlas") :outside-jail (wrap rooms.outside-jail/make "packed/outside-jail.atlas") :outside-castle (wrap rooms.outside-castle/make "packed/outside-castle.atlas") } + entities {:rooms rooms + :room-musics {:inside-house :inside-fangald + :inside-stash {:day :secret-hideout :night :secret-hideout} + :outside-house {:day :town-2 :night :night :sunrise :night} + :behind-house {:day :town-2 :night :night :sunrise :night} + :cat-tree {:day :town-2 :night :night :sunrise :night} + :inside-castle {:day :town-1 :night :night :sunrise :night} + :space :fight + :held :fight + :inside-cafeteria {:day :town-1 :night :night :sunrise :night} + :inside-antique :inside-antique + :inside-jail :inside-antique + :dream {:intro :wind :day :dream} + :ending :dream + :castle-gate {:day :town-2 :night :night} + :outside-jail {:day :town-1 :night :night :sunrise :night} + :outside-castle {:day :town-2 :night :night} } :step-particles (assoc (particle-effect "particles/step") :x 100 :y 100 :baseline 241) :cam {:zoom utils/min-zoom :ideal-x 160 diff --git a/desktop/src-common/advent/utils.clj b/desktop/src-common/advent/utils.clj index 011a503e..f22aa58e 100644 --- a/desktop/src-common/advent/utils.clj +++ b/desktop/src-common/advent/utils.clj @@ -497,8 +497,8 @@ (let [time (get-in entities [:state :time]) musics (:musics entities) override-music (musics (get-in entities [:music-override :value])) - current-music (musics (get-in entities [:room :music])) - current-time-music (musics (get-in entities [:room :music time]))] + current-music (musics (get-in entities [:room-musics (get-in entities [:state :last-room])])) + current-time-music (musics (get-in entities [:room-musics (get-in entities [:state :last-room]) time]))] (or override-music current-music current-time-music)))