tweening instead of manual.

This commit is contained in:
2015-02-07 15:36:41 -08:00
parent 50bb4ac179
commit 78479885b3
2 changed files with 23 additions and 15 deletions

View File

@@ -499,23 +499,19 @@
(doseq [[k] (get-in entities [:room :timers])]
(remove-timer! screen k))
(-> entities
(assoc-in [:transition]
(assoc (texture "black.png")
:scale-x 20
:scale-y 20
:baseline 9500
:opacity 0.1))
(assoc-in [:tweens :fade-out] (utils/tween :fade-out screen [:fade :opacity] 0.0 1.0 0.5))
(assoc-in [:cursor :current] :main)))
(continue [this screen entities]
(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))
(music! (get-in entities [:musics old-music]) :set-volume (max (- 1.0 (get-in entities [:fade :opacity])) 0.0)))
entities)
(done? [this screen entities]
(>= (get-in entities [:transition :opacity]) 1.0))
(>= (get-in entities [:fade :opacity]) 1.0))
(terminate [this screen entities]
(println "done")
(if-let [next-time (get-in entities [:state :next-time])]
(-> entities
(assoc-in [:state :time] next-time)
@@ -530,7 +526,8 @@
entities (-> entities
(assoc-in [:room] (get-in entities [:rooms new-background]))
(assoc-in [:room :entities :ego] ego)
(assoc-in [:state :last-room] new-background))
(assoc-in [:state :last-room] new-background)
(assoc-in [:tweens :fade-in] (utils/tween :fade-in screen [:fade :opacity] 1.0 0.0 0.5)))
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
@@ -549,16 +546,16 @@
(continue [this screen entities]
(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))
(music! (get-in entities [:musics new-music]) :set-volume (max (- 1.0 (get-in entities [:fade :opacity])) 0.0)))
entities)
(done? [this screen entities]
(<= (get-in entities [:transition :opacity]) 0.0))
(<= (get-in entities [:fade :opacity]) 0.0))
(terminate [this screen entities]
(doseq [[k [start time fn]] (get-in entities [:room :timers])]
(add-timer! screen k start time))
(dissoc entities :transition))
entities)
(can-skip? [this screen entities]
false))))

View File

@@ -375,16 +375,26 @@
:pull-sword (utils/make-music "pull-sword.ogg")
:night (utils/make-music "night.ogg")}
:state (get-state)
:fade (assoc (texture "black.png")
:scale-x 20
:scale-y 20
:baseline 9500
:opacity 0.0)
:actions {:object nil
:channel (chan)
:current nil
:script-running? false
:started? false}
:volume {:object nil
:value 0.0}
:cursor {:id "cursor"
:current :main
:last :main
:override nil
:last-pos [0 0]}
:tweens {:fade-in (utils/tween :fade-in screen [:fade :opacity] 1.0 0.0 1.5 :power 3.0)
:fade-in-music (utils/tween :fade-in-music screen [:volume :value] 0.0 1.0 1.5 :power 3.0)}
:all-items (assoc items/items :object nil)
:room (as-> (get rooms (:last-room (get-state))) room
(assoc-in room [:entities :ego] (get-ego screen (:start-pos room) ((:scale-fn room) (:start-pos room)))))
@@ -405,7 +415,8 @@
:on-render
(fn [screen [entities]]
(clear!)
(let [entities (update-cursor screen entities)
(let [entities (utils/apply-tweens screen entities (:tweens entities))
entities (update-cursor screen entities)
entities (update-from-script screen entities)
entities (update-from-hotspots screen entities)
entities (assoc-in entities [:room :entities :ego :last-frame] (get-in entities [:room :entities :ego :object]))