totally reworking music transitions.

This commit is contained in:
2015-02-11 19:29:20 -08:00
parent b4c0fdcc6e
commit 5fbb4f1f31
5 changed files with 62 additions and 40 deletions

View File

@@ -16,11 +16,11 @@
:baseline 1000))
(defn play-battle [entities anim]
(actions/transition-music entities :town-1 :fight)
(actions/transition-music entities :fight)
(actions/add-entity entities :fight (get-in @entities [:room :fight]))
(actions/add-entity entities :hands-fight (get-in @entities [:room :hands-fight]))
(actions/play-animation entities :hands-fight anim)
(actions/transition-music entities :fight :town-1)
(actions/transition-music entities nil)
(actions/remove-entity entities :hands-fight)
(actions/remove-entity entities :fight))

View File

@@ -100,11 +100,11 @@
(actions/transition-background entities :space [0 65])
(actions/walk-straight-to entities :ego [140 55] :face :right)
(actions/play-animation entities :blergh :appear :stop? false)
(actions/transition-music entities :town-1 :fight))
(actions/transition-music entities :fight))
(defn pull-sword [entities]
(actions/play-animation entities :ego :reach)
(actions/transition-music entities :town-1 :pull-sword)
(actions/transition-music entities :pull-sword)
(actions/add-entity entities :blackout (get-in @entities [:room :blackout]))
(actions/add-entity entities :pull-sword (get-in @entities [:room :pull-sword]))
(actions/play-animation entities :pull-sword :pull-sword)
@@ -112,7 +112,7 @@
(actions/remove-entity entities :sword)
(actions/remove-entity entities :pull-sword)
(actions/remove-entity entities :blackout)
(actions/transition-music entities :pull-sword :town-1)
(actions/transition-music entities nil)
(actions/do-dialogue entities :ego "That was weird."
:ego "I have to go show my friends!")

View File

@@ -60,9 +60,14 @@
(defn left-click [screen entities]
(let [{:keys [x y]} (input->screen screen {:x (:input-x screen) :y (:input-y screen)})]
(println "clicked " [x y])
(if ((:mouse-in? (:inventory entities)) x y)
(cond
((:mouse-in? (:inventory entities)) x y)
(click-inventory screen entities)
(utils/intersects? (:close entities) [x y])
(assoc-in entities [:tweens :fade-out] (utils/tween :fade-out screen [:fade :opacity] 0.0 1.0 1.0 :finish #(do (set-screen! @(resolve 'advent.core/advent) @(resolve 'advent.screens.title/title-screen))
%)))
:else
(let [interaction (first (filter #((:mouse-in? %) entities x y)
(get-in entities [:room :interactions])))
interacting-entity (first (sort-by (comp - :baseline) (filter #(and (:mouse-in? %)
@@ -358,7 +363,6 @@
(sound! (snd e) :play (* (/ (get-in entities [:ego :scale-x]) 1.5) 0.75))))))
(defscreen scene
:on-timer
(fn [screen [entities]]
@@ -406,6 +410,10 @@
:started? false}
:volume {:object nil
:value 0.0}
:music-override {:object nil
:value nil}
:close (assoc (texture "close.png") :x 304 :y 224 :width 16 :height 16 :baseline 9000)
:cursor {:id "cursor"
:current :main
:last :main
@@ -419,6 +427,7 @@
: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)}]
(music! (utils/get-current-music entities) :set-volume (get-in entities [:volume :value]))
(utils/play-sound (get-in entities [:musics (actions/get-music (get-in entities [:room :music]) (get-in entities [:state :time]))]))
@@ -455,6 +464,8 @@
all-entities (concat (vals entities) layers (vals (get-in entities [:room :entities])))]
(play-key-sounds (get-in entities [:room :entities]))
(when-let [current-music (utils/get-current-music entities)]
(music! current-music :set-volume (get-in entities [:volume :value]) ))
(label! (:fps entities) :set-text (str (game :fps)))
(render! screen (sort-by :baseline all-entities))