intro sequence shaping up.
This commit is contained in:
@@ -1 +1 @@
|
||||
{:sound-volume 64.0, :music-volume 23.0}
|
||||
{:sound-volume 0.0, :music-volume 0.0}
|
||||
@@ -5,6 +5,7 @@
|
||||
[advent.screens.rooms.common :as common]
|
||||
[advent.actions :as actions]
|
||||
[advent.screens.items :as items]
|
||||
[advent.tween :as tween]
|
||||
[advent.utils :as utils]
|
||||
[clojure.zip :as zip]
|
||||
[clojure.set :as set]
|
||||
@@ -17,15 +18,121 @@
|
||||
|
||||
(def walk-chan (a/chan))
|
||||
|
||||
(defn set-opacity [entities opacity tool-opacity]
|
||||
(-> entities
|
||||
(assoc-in [:room :layers 0 :opacity] opacity)
|
||||
(assoc-in [:room :layers 1 :opacity] opacity)
|
||||
(assoc-in [:room :layers 2 :opacity] opacity)
|
||||
(assoc-in [:room :layers 3 :opacity] opacity)
|
||||
(assoc-in [:room :layers 4 :opacity] opacity)
|
||||
(assoc-in [:room :layers 5 :opacity] opacity)
|
||||
(assoc-in [:room :layers 6 :opacity] opacity)
|
||||
(assoc-in [:room :entities :sword :opacity] tool-opacity)
|
||||
(assoc-in [:room :entities :broom :opacity] tool-opacity)
|
||||
(assoc-in [:room :entities :shovel :opacity] tool-opacity)
|
||||
(assoc-in [:room :entities :fairy-godfather :opacity] opacity)
|
||||
(assoc-in [:room :entities :sign :opacity] opacity)))
|
||||
|
||||
(defn fade-in [entities]
|
||||
(actions/run-action entities
|
||||
(begin [this screen entities]
|
||||
(-> entities
|
||||
(assoc-in [:tweens :fade-in]
|
||||
(tween/tween :fade-in screen [:room :layers 0 :opacity] 0.0 1.0 0.5 :ease tween/ease-in-out-quintic))))
|
||||
|
||||
(continue [this screen entities]
|
||||
(set-opacity entities (get-in entities [:room :layers 0 :opacity] ) 0.0))
|
||||
|
||||
(done? [this screen entities]
|
||||
(= 1.0 (get-in entities [:room :layers 0 :opacity])))
|
||||
|
||||
(terminate [this screen entities]
|
||||
entities)
|
||||
(can-skip? [this screen entities]
|
||||
false)))
|
||||
(defn fade-in-tools [entities]
|
||||
(actions/run-action entities
|
||||
(begin [this screen entities]
|
||||
(-> entities
|
||||
(assoc-in [:tweens :fade-in]
|
||||
(tween/tween :fade-in screen [:room :entities :sword :opacity] 0.0 1.0 0.5 :ease tween/ease-in-out-quintic))))
|
||||
|
||||
(continue [this screen entities]
|
||||
(set-opacity entities 1.0 (get-in entities [:room :entities :sword :opacity])))
|
||||
|
||||
(done? [this screen entities]
|
||||
(= 1.0 (get-in entities [:room :entities :sword :opacity])))
|
||||
|
||||
(terminate [this screen entities]
|
||||
entities)
|
||||
(can-skip? [this screen entities]
|
||||
false)))
|
||||
(defn do-intro [entities]
|
||||
(a/go
|
||||
(actions/do-dialogue entities
|
||||
:ego "Oh hi there!"
|
||||
:ego "I'm Faceplant, the great knight, and this is my dream!"
|
||||
:ego "Just like in real life, I can walk around if you just click somewhere on the screen."
|
||||
:ego "Give it a shot, whydontya?")
|
||||
(actions/walk-to entities :ego [100 100])
|
||||
(actions/talk entities :ego "I can also pick up stuff by clicking on it.")))
|
||||
(Thread/sleep 2000)
|
||||
(actions/do-dialogue entities
|
||||
:ego "What's going on?"
|
||||
:ego "Who turned out the lights?"
|
||||
:ego "I must be dreaming.")
|
||||
|
||||
(Thread/sleep 500)
|
||||
(actions/talk entities :fairy-godfather "Taaaaaaaaaaaaaaaaaa-")
|
||||
(particle-effect! (get-in @entities [:room :entities :magic]) :reset)
|
||||
(particle-effect! (get-in @entities [:room :entities :magic]) :start)
|
||||
(Thread/sleep 500)
|
||||
(fade-in entities)
|
||||
(Thread/sleep 100)
|
||||
(actions/talk entities :fairy-godfather "-daaaaaaaaaaaaa!")
|
||||
(Thread/sleep 1500)
|
||||
(actions/do-dialogue entities :ego "Umm... What was that all about?"
|
||||
:fairy-godfather "Welcome, young Tick, to the pit of fate."
|
||||
:ego "Err, who are you?"
|
||||
:ego "And how do you know my name?"
|
||||
:fairy-godfather "Why, I'm your fairy godfather of course!"
|
||||
:fairy-godfather "I've brought you here, Tick, to help choose your destiny."
|
||||
:fairy-godfather "Today you will choose your trade."
|
||||
:fairy-godfather "Let us see what your fate could bring!"
|
||||
:fairy-godfather "Behold!")
|
||||
(particle-effect! (get-in @entities [:room :entities :magic]) :reset)
|
||||
(particle-effect! (get-in @entities [:room :entities :magic]) :start)
|
||||
(fade-in-tools entities)
|
||||
|
||||
(actions/do-dialogue entities :ego "What are these things?"
|
||||
:fairy-godfather "These, young Tick, represent the potential destinies for your life."
|
||||
:fairy-godfather "They have been selected since the dawn of time."
|
||||
:fairy-godfather "These destinies are never mistaken."
|
||||
:ego "Soo, I've been destined to be a shovel since the dawn of time?"
|
||||
:fairy-godfather "No, no, no!")
|
||||
(actions/update-entities entities #(update-in % [:room :entities :fairy-godfather] dissoc :path))
|
||||
(actions/walk-straight-to entities :fairy-godfather [60 120] :speed 3.0 :update-baseline? false)
|
||||
(actions/update-entities entities (fn [e] (update-in e [:room :entities :fairy-godfather] assoc :path (catmull-rom-spline (map #(apply vector-2* %) [[60 120] [60 124]]) true))))
|
||||
(actions/do-dialogue entities :fairy-godfather "This shovel represents the job of grave-digger."
|
||||
:fairy-godfather "A simple job, for a simple fellow."
|
||||
:ego "Hey! "
|
||||
:ego "I'm not simple.")
|
||||
(actions/update-entities entities #(update-in % [:room :entities :fairy-godfather] dissoc :path))
|
||||
(actions/walk-straight-to entities :fairy-godfather [240 120] :speed 3.0 :update-baseline? false)
|
||||
(actions/update-entities entities (fn [e] (update-in e [:room :entities :fairy-godfather] assoc :path (catmull-rom-spline (map #(apply vector-2* %) [[240 120] [240 124]]) true))))
|
||||
(actions/do-dialogue entities :fairy-godfather "Next, we have the broom, representing the humble job of a janitor."
|
||||
:ego "I'm not going to be a janitor!"
|
||||
:ego "I'm going to take the sword and be a knight?"
|
||||
:fairy-godfather "Hmm? Sword?")
|
||||
(actions/update-entities entities #(update-in % [:room :entities :fairy-godfather] dissoc :path))
|
||||
(actions/walk-straight-to entities :fairy-godfather [170 120] :speed 3.0 :update-baseline? false)
|
||||
(actions/update-entities entities (fn [e] (update-in e [:room :entities :fairy-godfather] assoc :path (catmull-rom-spline (map #(apply vector-2* %) [[170 120] [170 124]]) true))))
|
||||
(actions/do-dialogue entities
|
||||
:fairy-godfather "Sword...?"
|
||||
:fairy-godfather "Uh, oh. That's not right."
|
||||
:fairy-godfather "Ahem."
|
||||
:fairy-godfather "You must choose between being a janitor and grave-digger."
|
||||
:ego "But I want to be a knight!"
|
||||
:ego "And you said that these destinies are never mistaken!"
|
||||
:fairy-godfather "Nevermind that."
|
||||
:fairy-godfather "Choose the broom or shovel, and cast it into the pit of fate."
|
||||
:ego "But..."
|
||||
:fairy-godfather "No buts.")
|
||||
(actions/update-state entities #(assoc % :seen-intro? true)))
|
||||
|
||||
|
||||
|
||||
(defn make [screen]
|
||||
(let [fairy-godfather-anim (utils/make-anim "dream/fairy-godfather.png" [63 77] 0.15 [0 1 2 3 2 1 0 1 4 3 2 1])
|
||||
@@ -36,10 +143,11 @@
|
||||
(assoc (texture "dream/island.png") :x 180 :y 180 :baseline 0 :parallax 0.3 :scale-x 1.1 :scale-y 1.1)
|
||||
(assoc (texture "dream/cliff.png") :x 50 :y 133 :baseline 1 :parallax 0.6 :scale-x 1.2 :scale-y 1.2)
|
||||
(assoc (texture "dream/background.png") :x 0 :y 0 :baseline 2)
|
||||
(assoc (texture "dream/corner-l.png") :x -10 :y -10 :baseline 240 :parallax 2.0)
|
||||
(assoc (texture "dream/corner-l.png") :x -10 :y -10 :baseline 240 :parallax 2.0 )
|
||||
(assoc (texture "dream/corner-r.png") :x (- 320 80) :y -20 :baseline 240 :parallax 3.2)
|
||||
(assoc (texture "dream/pedestals.png") :x 0 :y 0 :baseline 139)]
|
||||
:entities {:clouds (assoc (particle-effect "dream/cloudy2") :x 160 :y 120 :baseline 241)
|
||||
:entities {:magic (assoc (particle-effect "dream/magic") :x 160 :y 0 :baseline 240)
|
||||
:clouds (assoc (particle-effect "dream/cloudy2") :x 160 :y 120 :baseline 241)
|
||||
:sword (assoc (texture "dream/sword.png")
|
||||
:x 144 :y 122 :baseline 139
|
||||
:script (actions/get-script entities
|
||||
@@ -54,6 +162,7 @@
|
||||
:ego "And this plaque here says that chicks dig knights.")))
|
||||
:broom (assoc (texture "dream/broom.png") :x 286 :y 122
|
||||
:path (catmull-rom-spline (map #(apply vector-2* %) [[286 122] [286 128]]) true)
|
||||
|
||||
:update-fn (partial utils/update-path-location 0.30)
|
||||
:baseline 240
|
||||
:script (actions/get-script entities
|
||||
@@ -68,6 +177,7 @@
|
||||
:shovel (assoc (texture "dream/shovel.png") :x 33 :y 122
|
||||
:path (catmull-rom-spline (map #(apply vector-2* %) [[22 122] [22 128]]) true)
|
||||
:update-fn (partial utils/update-path-location 0.33)
|
||||
|
||||
:baseline 240
|
||||
:script (actions/get-script entities
|
||||
(actions/walk-to entities :ego [61 72] :face :left)
|
||||
@@ -79,13 +189,26 @@
|
||||
:sign (assoc (texture "dream/sign.png") :x 229 :y 33 :baseline 207)
|
||||
:fairy-godfather (assoc (animation->texture screen fairy-godfather-anim)
|
||||
:x 200 :y 130
|
||||
:baseline 150
|
||||
:talk fairy-godfather-talk-anim
|
||||
:stand fairy-godfather-anim
|
||||
:baseline 240
|
||||
:anim fairy-godfather-anim :anim-start 0
|
||||
:path (catmull-rom-spline (map #(apply vector-2* %) [[200 130] [200 134]]) true)
|
||||
:update-fn (partial utils/update-path-location 0.2)
|
||||
:script (actions/get-script entities (actions/do-dialogue entities :fairy-godfather "Young Tick, you must choose your destiny!")))}
|
||||
:left {:walk fairy-godfather-anim
|
||||
:talk fairy-godfather-talk-anim
|
||||
:stand fairy-godfather-anim}
|
||||
:right {:walk (utils/flip fairy-godfather-anim)
|
||||
:stand (utils/flip fairy-godfather-anim)
|
||||
:talk (utils/flip fairy-godfather-talk-anim)}
|
||||
:facing :left
|
||||
:update-fn (fn [s es e] (if (:path e)
|
||||
(utils/update-path-location 0.2 s es e)
|
||||
e))
|
||||
:script (actions/get-script entities
|
||||
|
||||
(actions/do-dialogue entities :fairy-godfather "Young Tick, you must choose your destiny!")))}
|
||||
:collision "dream/collision.png"
|
||||
:scale-fn (utils/scaler-fn-with-baseline 40 0.5 1.6)
|
||||
:apply-state (fn [entities]
|
||||
(if (get-in entities [:state :seen-intro?])
|
||||
(set-opacity entities 1.0 1.0)
|
||||
(set-opacity entities 0.0 0.0)))
|
||||
:start-pos [140 55])))
|
||||
|
||||
@@ -398,7 +398,7 @@
|
||||
(utils/load)
|
||||
{:object nil
|
||||
:active? true
|
||||
:last-room :outside-house
|
||||
:last-room :dream
|
||||
:time :day
|
||||
:obtained-items #{}
|
||||
:inventory []
|
||||
@@ -411,7 +411,11 @@
|
||||
(do (music! (utils/get-current-music entities) :set-volume (utils/current-music-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]))]))
|
||||
(assoc entities
|
||||
:tweens {:fade-in (tween/tween :fade-in screen [:fade :opacity] 1.0 0.0 1.0 :ease tween/ease-in-cubic)
|
||||
:tweens {:fade-in (tween/tween :fade-in screen [:fade :opacity] 1.0 0.0 1.0 :ease tween/ease-in-cubic
|
||||
:finish #(if (not (get-in % [:state :seen-intro?]))
|
||||
(do ((actions/get-script % (rooms.dream/do-intro %)) entities)
|
||||
(assoc-in % [:actions :script-running?] true))
|
||||
%))
|
||||
:fade-in-music (tween/tween :fade-in-music screen [:volume :value] 0.0 1.0 1.0 :ease tween/ease-in-cubic)}
|
||||
:started? {:value true
|
||||
:object nil}))
|
||||
@@ -466,12 +470,16 @@
|
||||
(.begin batch)
|
||||
(.setProjectionMatrix batch parallax-combined)
|
||||
|
||||
(.setColor batch (color 1 1 1 (or (:opacity e) 1.0)))
|
||||
|
||||
|
||||
(entities/draw! (assoc e :x (+ (/ (:x e) (.zoom camera))
|
||||
(- (* 320 parallax 0.5)
|
||||
(/ 160 (.zoom camera)) ))
|
||||
:y (+ (/ (:y e) (.zoom camera))
|
||||
(- (* 240 parallax 0.5)
|
||||
(/ 120 (.zoom camera))))) screen batch)
|
||||
(.setColor batch (color 1 1 1 1))
|
||||
(.end batch))))
|
||||
|
||||
|
||||
@@ -570,8 +578,7 @@
|
||||
|
||||
(doseq [[k [start time fn]] (get-in entities [:room :timers])]
|
||||
(add-timer! screen k start time))
|
||||
#_(when (not (get-in entities [:state :seen-intro?]))
|
||||
((actions/get-script entities (rooms.dream/do-intro entities)) entities))
|
||||
|
||||
|
||||
|
||||
(if-let [apply-state (get-in entities [:room :apply-state])]
|
||||
|
||||
@@ -125,7 +125,7 @@
|
||||
(assoc entity :x (vector-2! v :x) :y (vector-2! v :y)))))))
|
||||
|
||||
(defn update-path-location [speed screen entities entity]
|
||||
(let [pos-f (- (* (:total-time screen) speed) (int (* (:total-time screen) speed)))
|
||||
(let [pos-f (- (* (- (:total-time screen) (:path-start-time entity 0.0)) speed) (int (* (- (:total-time screen) (:path-start-time entity 0.0)) speed)))
|
||||
v (vector-2 0 0)
|
||||
a (catmull-rom-spline! (:path entity) :value-at v pos-f)]
|
||||
(assoc entity :x (vector-2! v :x) :y (vector-2! v :y))))
|
||||
|
||||
Reference in New Issue
Block a user