fading music.
This commit is contained in:
@@ -336,55 +336,63 @@
|
|||||||
false)))
|
false)))
|
||||||
|
|
||||||
(defn transition-background [entities new-background [x y]]
|
(defn transition-background [entities new-background [x y]]
|
||||||
(run-action entities
|
(let [old-music (get-in @entities [:room :music])
|
||||||
(begin [this screen entities]
|
new-music (get-in @entities [:rooms new-background :music])
|
||||||
|
music-changed? (not= old-music new-music)]
|
||||||
(-> entities
|
(run-action entities
|
||||||
(assoc-in [:transition]
|
(begin [this screen entities]
|
||||||
(assoc (texture "black.png")
|
|
||||||
:scale-x 20
|
|
||||||
:scale-y 20
|
|
||||||
:baseline 9500
|
|
||||||
:opacity 0.1))))
|
|
||||||
|
|
||||||
(continue [this screen entities]
|
|
||||||
(update-in entities [:transition :opacity] + 0.075))
|
|
||||||
|
|
||||||
(done? [this screen entities]
|
|
||||||
(>= (get-in entities [:transition :opacity]) 1.0))
|
|
||||||
|
|
||||||
(terminate [this screen entities]
|
|
||||||
entities)
|
|
||||||
(can-skip? [this screen entities]
|
|
||||||
false))
|
|
||||||
(run-action entities
|
|
||||||
(begin [this screen entities]
|
|
||||||
(let [ego (get-in entities [:room :entities :ego])
|
|
||||||
old-music (get-in entities [:room :music])
|
|
||||||
entities (-> entities
|
|
||||||
(assoc-in [:room] (get-in entities [:rooms new-background]))
|
|
||||||
(assoc-in [:room :entities :ego] ego))
|
|
||||||
new-music (get-in entities [:room :music])]
|
|
||||||
(when (not= new-music old-music)
|
|
||||||
(doseq [[k v] (:musics entities)
|
|
||||||
:when (and v (not= new-music k))]
|
|
||||||
(music! v :stop))
|
|
||||||
(when new-music
|
|
||||||
(music! (get-in entities [:musics new-music]) :play)))
|
|
||||||
(-> entities
|
(-> entities
|
||||||
(update-in [:room :entities :ego] #(jump-to screen entities % [x y])))))
|
(assoc-in [:transition]
|
||||||
|
(assoc (texture "black.png")
|
||||||
|
:scale-x 20
|
||||||
|
:scale-y 20
|
||||||
|
:baseline 9500
|
||||||
|
:opacity 0.1))))
|
||||||
|
|
||||||
(continue [this screen entities]
|
(continue [this screen entities]
|
||||||
(update-in entities [:transition :opacity] - 0.075))
|
(when music-changed?
|
||||||
|
(music! (get-in entities [:musics old-music]) :set-volume (max (- 1.0 (get-in entities [:transition :opacity])) 0.0)))
|
||||||
|
(update-in entities [:transition :opacity] + 0.05))
|
||||||
|
|
||||||
(done? [this screen entities]
|
(done? [this screen entities]
|
||||||
(<= (get-in entities [:transition :opacity]) 0.0))
|
(>= (get-in entities [:transition :opacity]) 1.0))
|
||||||
|
|
||||||
(terminate [this screen entities]
|
(terminate [this screen entities]
|
||||||
(dissoc entities :transition))
|
entities)
|
||||||
|
(can-skip? [this screen entities]
|
||||||
|
false))
|
||||||
|
(run-action entities
|
||||||
|
(begin [this screen entities]
|
||||||
|
(let [ego (get-in entities [:room :entities :ego])
|
||||||
|
old-music (get-in entities [:room :music])
|
||||||
|
entities (-> entities
|
||||||
|
(assoc-in [:room] (get-in entities [:rooms new-background]))
|
||||||
|
(assoc-in [:room :entities :ego] ego))
|
||||||
|
new-music (get-in entities [:room :music])]
|
||||||
|
(when (not= new-music old-music)
|
||||||
|
(doseq [[k v] (:musics entities)
|
||||||
|
:when (and v (not= new-music k))]
|
||||||
|
(music! v :stop))
|
||||||
|
(when new-music
|
||||||
|
(music! (get-in entities [:musics new-music]) :set-volume 0)
|
||||||
|
(music! (get-in entities [:musics new-music]) :play)))
|
||||||
|
(-> entities
|
||||||
|
(update-in [:room :entities :ego] #(jump-to screen entities % [x y])))))
|
||||||
|
|
||||||
(can-skip? [this screen entities]
|
(continue [this screen entities]
|
||||||
false)))
|
(when music-changed?
|
||||||
|
(music! (get-in entities [:musics new-music]) :set-volume (max (- 1.0 (get-in entities [:transition :opacity])) 0.0)))
|
||||||
|
(update-in entities [:transition :opacity] - 0.075))
|
||||||
|
|
||||||
|
(done? [this screen entities]
|
||||||
|
(<= (get-in entities [:transition :opacity]) 0.0))
|
||||||
|
|
||||||
|
(terminate [this screen entities]
|
||||||
|
(dissoc entities :transition))
|
||||||
|
|
||||||
|
(can-skip? [this screen entities]
|
||||||
|
false))))
|
||||||
|
|
||||||
(defn do-dialogue [entities & pairs]
|
(defn do-dialogue [entities & pairs]
|
||||||
(loop [pairs (partition 2 pairs)]
|
(loop [pairs (partition 2 pairs)]
|
||||||
|
|||||||
Reference in New Issue
Block a user