From 78479885b3f6b4697838bf7e55c7b2aeb20269d6 Mon Sep 17 00:00:00 2001 From: Remington Covert Date: Sat, 7 Feb 2015 15:36:41 -0800 Subject: [PATCH] tweening instead of manual. --- desktop/src-common/advent/actions.clj | 25 +++++++++------------ desktop/src-common/advent/screens/scene.clj | 13 ++++++++++- 2 files changed, 23 insertions(+), 15 deletions(-) diff --git a/desktop/src-common/advent/actions.clj b/desktop/src-common/advent/actions.clj index 402b91c5..f2a4950f 100644 --- a/desktop/src-common/advent/actions.clj +++ b/desktop/src-common/advent/actions.clj @@ -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)))) diff --git a/desktop/src-common/advent/screens/scene.clj b/desktop/src-common/advent/screens/scene.clj index 005c98f5..4e8fc8a3 100644 --- a/desktop/src-common/advent/screens/scene.clj +++ b/desktop/src-common/advent/screens/scene.clj @@ -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]))