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

View File

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