From 9a331cba0704e9651406bcaaea03837d2bbb00d8 Mon Sep 17 00:00:00 2001 From: Remington Covert Date: Tue, 4 Nov 2014 12:50:48 -0800 Subject: [PATCH] music and latest version. --- desktop/src-common/advent/actions.clj | 14 ++-- .../src-common/advent/screens/inventory.clj | 4 +- .../advent/screens/rooms/inside_house.clj | 2 +- desktop/src-common/advent/screens/scene.clj | 66 ++++++++++--------- 4 files changed, 45 insertions(+), 41 deletions(-) diff --git a/desktop/src-common/advent/actions.clj b/desktop/src-common/advent/actions.clj index 66df5590..2dee2dcc 100644 --- a/desktop/src-common/advent/actions.clj +++ b/desktop/src-common/advent/actions.clj @@ -207,7 +207,7 @@ scale-fn (get-in entities [:room :scale-fn]) scale (scale-fn [target-x target-y]) height (* scale 36)] - (run! dialogue/talking-screen :on-talk :text text + (screen! dialogue/talking-screen :on-talk :text text :x (get-in entities [:room :entities target-id :x]) :y (+ (get-in entities [:room :entities target-id :y]) height) :target-id target-id :scale scale) @@ -221,7 +221,7 @@ (get-text-duration text))) (terminate [this screen entities] - (run! dialogue/talking-screen :stop-talk :target-id target-id) + (screen! dialogue/talking-screen :stop-talk :target-id target-id) (if stop? (stop screen entities target-id) entities)) @@ -251,8 +251,8 @@ dialogue-choices (filter first (partition 2 (:choices node)))] (run-action entities (begin [this screen entities] - (run! dialogue/choice-screen :on-present-choices :choices dialogue-choices :callback #(reset! selected-index %)) - (run! @(resolve 'advent.screens.scene/scene) :on-deactivate) + (screen! dialogue/choice-screen :on-present-choices :choices dialogue-choices :callback #(reset! selected-index %)) + (screen! @(resolve 'advent.screens.scene/scene) :on-deactivate) entities) (continue [this screen entities] entities) @@ -260,7 +260,7 @@ (done? [this screen entities] (not (nil? @selected-index))) (terminate [this screen entities] - (run! @(resolve 'advent.screens.scene/scene) :on-reactivate) + (screen! @(resolve 'advent.screens.scene/scene) :on-reactivate) entities) (can-skip? [this screen entities] false)) @@ -368,9 +368,9 @@ (when (not= new-music old-music) (doseq [[k v] (:musics entities) :when (and v (not= new-music k))] - (sound! v :stop)) + (music! v :stop)) (when new-music - (sound! (get-in entities [:musics new-music]) :loop 0.30))) + (music! (get-in entities [:musics new-music]) :play))) (-> entities (update-in [:room :entities :ego] #(jump-to screen entities % [x y]))))) diff --git a/desktop/src-common/advent/screens/inventory.clj b/desktop/src-common/advent/screens/inventory.clj index bf3e852f..9bd98c11 100644 --- a/desktop/src-common/advent/screens/inventory.clj +++ b/desktop/src-common/advent/screens/inventory.clj @@ -15,7 +15,7 @@ (defn close [entities] - (run! @(resolve 'advent.screens.scene/scene) :on-reactivate) + (screen! @(resolve 'advent.screens.scene/scene) :on-reactivate) (-> entities (assoc :shown? false) (assoc :start-showing? false))) @@ -90,7 +90,7 @@ current-cursor (get-in room-entities [:cursor :current])] (if highlighted-item (if (= :main current-cursor) - (run! @(resolve 'advent.screens.scene/scene) :on-chose-item :item highlighted-item) + (screen! @(resolve 'advent.screens.scene/scene) :on-chose-item :item highlighted-item) (when-let [interaction-script ((or (:scripts highlighted-item) (constantly nil)) (:value current-cursor))] (interaction-script room-entities) (close entities))) diff --git a/desktop/src-common/advent/screens/rooms/inside_house.clj b/desktop/src-common/advent/screens/rooms/inside_house.clj index 4d66c2cb..cfd9159a 100644 --- a/desktop/src-common/advent/screens/rooms/inside_house.clj +++ b/desktop/src-common/advent/screens/rooms/inside_house.clj @@ -31,7 +31,7 @@ :layers [(assoc (texture "inside-house/background.png") :x 0 :y 0 :baseline 0) (assoc (texture "inside-house/desk.png") :x 0 :y 0 :baseline 200) (assoc (texture "inside-house/sillhoute.png") :x 0 :y 0 :baseline 240)] - :entities {:wizard (actions/start-animation screen (assoc (animation->texture screen wizard-stand) :x 228 :y 80 :baseline 160 :scale-x 1.75 :scale-y 1.75 + :entities {:wizard (actions/start-animation screen (assoc (animation->texture (doto screen) wizard-stand) :x 228 :y 80 :baseline 160 :scale-x 1.75 :scale-y 1.75 :left {:talk (utils/flip wizard-talk) :stand (utils/flip wizard-stand)} :right {:talk wizard-talk diff --git a/desktop/src-common/advent/screens/scene.clj b/desktop/src-common/advent/screens/scene.clj index c2301119..9f2ee1ff 100644 --- a/desktop/src-common/advent/screens/scene.clj +++ b/desktop/src-common/advent/screens/scene.clj @@ -40,7 +40,7 @@ (get-in entities [:room :interactions])))) (defn open-inventory [screen entities] - (run! inventory-screen :show-screen :items (get-in entities [:state :inventory])) + (screen! inventory-screen :show-screen :items (get-in entities [:state :inventory])) (assoc-in entities [:state :active?] false)) @@ -155,40 +155,44 @@ (:anim entity)))) (defn play-sound [snd] - (sound! snd :loop 0.3)) + (music! snd :play)) + +(defn make-music [r] + (doto (music r) (music! :set-looping true))) (defscreen scene :on-show (fn [screen entities] - (update! screen :renderer (stage) :camera (orthographic)) - (let [_ (input! :set-cursor-image (utils/cursor "cursor.png" :main) 0 0) - rooms {:inside-house (rooms.inside-house/make screen) - :outside-house (rooms.outside-house/make screen) - :behind-house (rooms.behind-house/make screen) - :cat-tree (rooms.cat-tree/make screen) - :inside-castle (rooms.inside-castle/make screen) - :outside-castle (rooms.outside-castle/make screen)}] - {:rooms rooms - :musics {:object nil - :town-1 (sound "town-music.mp3") - :town-2 (doto (sound "town-music-2.mp3") play-sound) - :inside-fangald (sound "inside-fangald.mp3")} - :state {:object nil - :active? true - :inventory []} - :actions {:object nil - :channel (chan) - :current nil - :started? false} - :cursor {:id "cursor" - :current :main - :last :main - :override nil} - :room (assoc-in (:outside-house rooms) - [:entities :ego] (get-ego screen)) - :inventory (assoc (texture "inventory.png") :x 278 :y 0 :baseline 9000 - :mouse-in? (zone/box 278 0 320 42)) - :fps (assoc (label "0" (color :white) ) :x 5 :baseline 0)})) + (let [screen (assoc screen :total-time 0)] + (update! screen :renderer (stage) :camera (orthographic)) + (let [_ (input! :set-cursor-image (utils/cursor "cursor.png" :main) 0 0) + rooms {:inside-house (rooms.inside-house/make screen) + :outside-house (rooms.outside-house/make screen) + :behind-house (rooms.behind-house/make screen) + :cat-tree (rooms.cat-tree/make screen) + :inside-castle (rooms.inside-castle/make screen) + :outside-castle (rooms.outside-castle/make screen)}] + {:rooms rooms + :musics {:object nil + :town-1 (make-music "town-music-1.ogg") + :town-2 (doto (make-music "town-music-2.ogg") play-sound) + :inside-fangald (make-music "inside-fangald.ogg")} + :state {:object nil + :active? true + :inventory []} + :actions {:object nil + :channel (chan) + :current nil + :started? false} + :cursor {:id "cursor" + :current :main + :last :main + :override nil} + :room (assoc-in (:outside-house rooms) + [:entities :ego] (get-ego screen)) + :inventory (assoc (texture "inventory.png") :x 278 :y 0 :baseline 9000 + :mouse-in? (zone/box 278 0 320 42)) + :fps (assoc (label "0" (color :white) ) :x 5 :baseline 0)}))) :on-render (fn [screen [entities]]