prepatory cleanup.
This commit is contained in:
@@ -47,6 +47,16 @@
|
|||||||
|
|
||||||
(def do-once (atom false))
|
(def do-once (atom false))
|
||||||
|
|
||||||
|
(defn quit [screen entities]
|
||||||
|
(do (input! :set-cursor-image (utils/cursor "cursor.png" :hourglass) 0 0)
|
||||||
|
(-> entities
|
||||||
|
(assoc-in [:tweens :fade-out]
|
||||||
|
(tween/tween :fade-out screen [:fade :opacity] 0.0 1.0 1.0
|
||||||
|
:finish (fn [entities]
|
||||||
|
(System/exit 0)
|
||||||
|
entities)
|
||||||
|
:ease tween/ease-in-cubic)))))
|
||||||
|
|
||||||
(defn fly-balloon [screen entities]
|
(defn fly-balloon [screen entities]
|
||||||
(let [speed 0.03
|
(let [speed 0.03
|
||||||
pos-f (- (* (:total-time screen) speed) (int (* (:total-time screen) speed)))
|
pos-f (- (* (:total-time screen) speed) (int (* (:total-time screen) speed)))
|
||||||
@@ -82,38 +92,63 @@
|
|||||||
"Continue quest"
|
"Continue quest"
|
||||||
"Begin quest"))
|
"Begin quest"))
|
||||||
|
|
||||||
|
(defn start-playing [screen entities]
|
||||||
|
(do (input! :set-cursor-image (utils/cursor "cursor.png" :hourglass) 0 0)
|
||||||
|
(-> entities
|
||||||
|
(assoc-in [:tweens :fade-out]
|
||||||
|
(tween/tween :fade-out screen [:fade :opacity] 0.0 1.0 1.0
|
||||||
|
:finish (fn [entities]
|
||||||
|
(utils/stop-sound (:music entities))
|
||||||
|
(set-screen! @(resolve 'advent.core/advent) scene/scene scene/demo scene/hud dialogue/talking-screen dialogue/choice-screen inventory/inventory-screen safe/safe-screen fade/fade-screen
|
||||||
|
)
|
||||||
|
entities)
|
||||||
|
:ease tween/ease-in-cubic))
|
||||||
|
(assoc-in [:tweens :fade-out-music]
|
||||||
|
(tween/tween :fade-out-music screen [:volume] 1.0 0.0 1.0)))))
|
||||||
|
|
||||||
|
(defn make-label
|
||||||
|
([msg]
|
||||||
|
(make-label msg (color 1.0 0.3 0.3 1.0)))
|
||||||
|
([msg col]
|
||||||
|
(let [font (utils/get-font "ego/font.fnt")]
|
||||||
|
(-> msg
|
||||||
|
(label (style :label font col))
|
||||||
|
(assoc :x 0 :y 0 :height 32 :origin-x 0 :origin-y 0 :z 8)
|
||||||
|
center
|
||||||
|
(doto (label! :set-alignment Align/center))))))
|
||||||
|
|
||||||
|
(defn stack-y [label base index]
|
||||||
|
(assoc label :y (- 280 (* 32 index))))
|
||||||
|
|
||||||
(defscreen title-screen
|
(defscreen title-screen
|
||||||
:on-show
|
:on-show
|
||||||
(fn [screen entities]
|
(fn [screen entities]
|
||||||
(utils/setup-viewport screen 1280 960)
|
(utils/setup-viewport screen 1280 960)
|
||||||
(utils/load-settings!)
|
(utils/load-settings!)
|
||||||
(let [font (utils/get-font "ego/font.fnt")
|
(let [font (utils/get-font "ego/font.fnt")
|
||||||
start-playing (assoc (label (quest-label) (style :label font (color 1.0 0.3 0.3 1.0))) :x 0 :y 280 :height 32 :origin-x 0 :origin-y 0)
|
start-playing (-> (make-label (quest-label))
|
||||||
start-playing (center start-playing)
|
(stack-y 280 0))
|
||||||
copyright (assoc (label "DEMO - Copyright Bryce Covert - Not for distribution" (style :label font (color 1.0 0.3 0.3 1.0))) :x 0 :y 0 :height 32 :origin-x 0 :origin-y 0)
|
copyright (make-label "DEMO - Copyright Bryce Covert - Not for distribution")
|
||||||
copyright (center copyright)
|
fullscreen (-> (make-label "Fullscreen")
|
||||||
fullscreen (assoc (label "Fullscreen" (style :label font (color 1.0 0.3 0.3 1.0))) :x 0 :y (- 280 (* 32 5)) :height 32 :origin-x 0 :origin-y 0)
|
(stack-y 280 5))
|
||||||
fullscreen (center fullscreen)
|
quit (-> (make-label "End quest")
|
||||||
quit (assoc (label "End quest" (style :label font (color 1.0 0.3 0.3 1.0))) :x 0 :y (- 280 (* 32 6)) :height 32 :origin-x 0 :origin-y 0)
|
(stack-y 280 6))
|
||||||
quit (center quit)
|
|
||||||
music (utils/make-music "music/intro.ogg")
|
music (utils/make-music "music/intro.ogg")
|
||||||
ui-skin (skin "ui/ui.json")
|
ui-skin (skin "ui/ui.json")
|
||||||
balloon (utils/make-anim "title/balloon.png" [15 30] 0.45 (range 4))
|
balloon (utils/make-anim "title/balloon.png" [15 30] 0.45 (range 4))]
|
||||||
]
|
|
||||||
(label! start-playing :set-alignment Align/center)
|
|
||||||
(label! quit :set-alignment Align/center)
|
|
||||||
(label! fullscreen :set-alignment Align/center)
|
|
||||||
(input! :set-cursor-image (utils/cursor "cursor.png" :hourglass) 0 0)
|
(input! :set-cursor-image (utils/cursor "cursor.png" :hourglass) 0 0)
|
||||||
|
|
||||||
{:background (assoc (utils/get-texture "title/background.png" ) :x 0 :y 0 :scale-x 4 :scale-y 4 :origin-x 0 :origin-y 0)
|
{:background (assoc (utils/get-texture "title/background.png" ) :x 0 :y 0 :scale-x 4 :scale-y 4 :origin-x 0 :origin-y 0 :z 0)
|
||||||
:cloud-background (assoc (utils/get-texture "title/clouds.png" ) :x 0 :y 0 :scale-x 4 :scale-y 4 :origin-x 0 :origin-y 0)
|
:cloud-background (assoc (utils/get-texture "title/clouds.png" ) :x 0 :y 0 :scale-x 4 :scale-y 4 :origin-x 0 :origin-y 0 :z 2)
|
||||||
:logo (assoc (utils/get-texture "title/logo.png" ) :x 0 :y 0 :scale-x 4 :scale-y 4 :origin-x 0 :origin-y 0)
|
:logo (assoc (utils/get-texture "title/logo.png" ) :x 0 :y 0 :scale-x 4 :scale-y 4 :origin-x 0 :origin-y 0 :z 6)
|
||||||
:fade (assoc (utils/get-texture "black.png")
|
:fade (assoc (utils/get-texture "black.png")
|
||||||
:scale-x 80
|
:scale-x 80
|
||||||
:scale-y 80
|
:scale-y 80
|
||||||
:opacity 1.0
|
:opacity 1.0
|
||||||
:origin-x 0
|
:origin-x 0
|
||||||
:origin-y 0)
|
:origin-y 0
|
||||||
|
:z 100)
|
||||||
:flying-ego (assoc (utils/get-texture "ego/flying.png")
|
:flying-ego (assoc (utils/get-texture "ego/flying.png")
|
||||||
:left (flip (utils/get-texture "ego/flying.png"))
|
:left (flip (utils/get-texture "ego/flying.png"))
|
||||||
:right (utils/get-texture "ego/flying.png")
|
:right (utils/get-texture "ego/flying.png")
|
||||||
@@ -123,38 +158,40 @@
|
|||||||
:origin-y 0
|
:origin-y 0
|
||||||
:path (catmull-rom-spline (map #(apply vector-2* %) [[-800 450] [1280 450] [2000 100] [0 100] [-800 300] [1280 300] [2000 450]]) true)
|
:path (catmull-rom-spline (map #(apply vector-2* %) [[-800 450] [1280 450] [2000 100] [0 100] [-800 300] [1280 300] [2000 450]]) true)
|
||||||
:x 450
|
:x 450
|
||||||
:y 650)
|
:y 650
|
||||||
|
:z 5)
|
||||||
:balloon (assoc (animation->texture (assoc screen :total-time 0.0) balloon) :x 100 :y 100 :scale-x 4 :scale-y 4
|
:balloon (assoc (animation->texture (assoc screen :total-time 0.0) balloon) :x 100 :y 100 :scale-x 4 :scale-y 4
|
||||||
:anim balloon
|
:anim balloon
|
||||||
:path (catmull-rom-spline (map #(apply vector-2* %) [[50 50] [70 100] [100 200] [151 206] [300 225] [480 300] [560 400] [650 440] [700 550] [750 600] [860 650] [950 700] [1030 800] [1280 960] [1300 1000] [-50 1000] [-50 -50]]) true))
|
:path (catmull-rom-spline (map #(apply vector-2* %) [[50 50] [70 100] [100 200] [151 206] [300 225] [480 300] [560 400] [650 440] [700 550] [750 600] [860 650] [950 700] [1030 800] [1280 960] [1300 1000] [-50 1000] [-50 -50]]) true)
|
||||||
:particle-clouds (assoc (particle-effect "particles/particle-clouds" :reset :start) :x 640 :y 480 )
|
:z 3)
|
||||||
:ego-jet (assoc (particle-effect "particles/jet" :reset :start) :x 450 :y 650 )
|
:particle-clouds (assoc (particle-effect "particles/particle-clouds" :reset :start) :x 640 :y 480 :z 1)
|
||||||
|
:ego-jet (assoc (particle-effect "particles/jet" :reset :start) :x 450 :y 650 :z 4)
|
||||||
:toolbox (center (assoc (nine-patch {:region (:object (utils/get-texture "talk-bg-2.png")) :left 9 :top 9 :right 9 :bottom 9})
|
:toolbox (center (assoc (nine-patch {:region (:object (utils/get-texture "talk-bg-2.png")) :left 9 :top 9 :right 9 :bottom 9})
|
||||||
:y 58 :width 500 :height 282))
|
:y 58 :width 500 :height 282
|
||||||
|
:z 7))
|
||||||
|
|
||||||
:music-label (-> (label "Music" (style :label font (color 1.0 1.0 1.0 1.0)))
|
:music-label (-> (make-label "Music" (color :white))
|
||||||
(assoc :x 0 :y (- 280 (* 32 1)) :height 32 :origin-x 0 :origin-y 0)
|
(stack-y 280 1))
|
||||||
center)
|
|
||||||
:music-volume-slider (-> (slider {:min 0 :max 100 :step 1} ui-skin :set-value (:music-volume @utils/settings))
|
:music-volume-slider (-> (slider {:min 0 :max 100 :step 1} ui-skin :set-value (:music-volume @utils/settings))
|
||||||
(assoc :x (- (/ 1280 2) 150)
|
(assoc :x (- (/ 1280 2) 150)
|
||||||
:width 300
|
:width 300
|
||||||
:y (- 280 (* 32 2))
|
:y (- 280 (* 32 2))
|
||||||
:hover (skin! ui-skin :get "default-horizontal-hover" Slider$SliderStyle)
|
:hover (skin! ui-skin :get "default-horizontal-hover" Slider$SliderStyle)
|
||||||
:default (skin! ui-skin :get "default-horizontal" Slider$SliderStyle)))
|
:default (skin! ui-skin :get "default-horizontal" Slider$SliderStyle)
|
||||||
|
:z 8))
|
||||||
|
|
||||||
:sound-label (->
|
:sound-label (-> (make-label "FX" (color :white))
|
||||||
(label "FX" (style :label font (color 1.0 1.0 1.0 1.0)))
|
(stack-y 280 3))
|
||||||
(assoc :x 0 :y (- 280 (* 32 3)) :height 32 :origin-x 0 :origin-y 0)
|
|
||||||
center)
|
|
||||||
|
|
||||||
|
|
||||||
:sound-volume-slider (assoc (slider {:min 0 :max 100 :step 1 } ui-skin :set-value (:sound-volume @utils/settings))
|
:sound-volume-slider (assoc (slider {:min 0 :max 100 :step 1 } ui-skin :set-value (:sound-volume @utils/settings))
|
||||||
:width 300
|
:width 300
|
||||||
:x ( - (/ 1280 2)
|
:x ( - (/ 1280 2)
|
||||||
150)
|
150)
|
||||||
:y (- 280 (* 32 4))
|
:y (- 280 (* 32 4))
|
||||||
:hover (skin! ui-skin :get "default-horizontal-hover" Slider$SliderStyle)
|
:z 8
|
||||||
:default (skin! ui-skin :get "default-horizontal" Slider$SliderStyle))
|
:hover (skin! ui-skin :get "default-horizontal-hover" Slider$SliderStyle)
|
||||||
|
:default (skin! ui-skin :get "default-horizontal" Slider$SliderStyle))
|
||||||
:font font
|
:font font
|
||||||
:music music
|
:music music
|
||||||
:volume 1.0
|
:volume 1.0
|
||||||
@@ -183,7 +220,7 @@
|
|||||||
"Windowed"))
|
"Windowed"))
|
||||||
(music! (:music entities) :set-volume (utils/current-music-volume (:volume entities)))
|
(music! (:music entities) :set-volume (utils/current-music-volume (:volume entities)))
|
||||||
|
|
||||||
(render! screen [(:background entities) (:particle-clouds entities) (:cloud-background entities) (:balloon entities) (:ego-jet entities) (:flying-ego entities) (:logo entities) (:toolbox entities) (:start-playing entities) (:quit entities) (:fullscreen entities) (:music-label entities) (:music-volume-slider entities) (:sound-label entities) (:sound-volume-slider entities) (:copyright entities) (:fade entities) ])
|
(render! screen (sort-by :z (filter :object (vals entities))) )
|
||||||
entities))
|
entities))
|
||||||
|
|
||||||
:show-screen (fn [entities]
|
:show-screen (fn [entities]
|
||||||
@@ -214,38 +251,20 @@
|
|||||||
entities)
|
entities)
|
||||||
|
|
||||||
:on-touch-up (fn [screen [entities]]
|
:on-touch-up (fn [screen [entities]]
|
||||||
|
|
||||||
(when-not (get-in entities [:tweens :fade-out])
|
(when-not (get-in entities [:tweens :fade-out])
|
||||||
(let [[x y] (utils/unproject screen)]
|
(let [[x y] (utils/unproject screen)]
|
||||||
(cond
|
(cond
|
||||||
(utils/intersects? (:start-playing entities) [x y])
|
(utils/intersects? (:start-playing entities) [x y])
|
||||||
(do (input! :set-cursor-image (utils/cursor "cursor.png" :hourglass) 0 0)
|
(start-playing screen entities)
|
||||||
(-> entities
|
|
||||||
(assoc-in [:tweens :fade-out]
|
|
||||||
(tween/tween :fade-out screen [:fade :opacity] 0.0 1.0 1.0
|
|
||||||
:finish (fn [entities]
|
|
||||||
(utils/stop-sound (:music entities))
|
|
||||||
(set-screen! @(resolve 'advent.core/advent) scene/scene scene/demo scene/hud dialogue/talking-screen dialogue/choice-screen inventory/inventory-screen safe/safe-screen fade/fade-screen
|
|
||||||
)
|
|
||||||
entities)
|
|
||||||
:ease tween/ease-in-cubic))
|
|
||||||
(assoc-in [:tweens :fade-out-music]
|
|
||||||
(tween/tween :fade-out-music screen [:volume] 1.0 0.0 1.0))))
|
|
||||||
(utils/intersects? (:quit entities) [x y])
|
|
||||||
(do (input! :set-cursor-image (utils/cursor "cursor.png" :hourglass) 0 0)
|
|
||||||
(-> entities
|
|
||||||
(assoc-in [:tweens :fade-out]
|
|
||||||
(tween/tween :fade-out screen [:fade :opacity] 0.0 1.0 1.0
|
|
||||||
:finish (fn [entities]
|
|
||||||
(System/exit 0)
|
|
||||||
entities)
|
|
||||||
:ease tween/ease-in-cubic))))
|
|
||||||
|
|
||||||
(utils/intersects? (:fullscreen entities) [x y])
|
(utils/intersects? (:quit entities) [x y])
|
||||||
(utils/toggle-fullscreen!)
|
(quit screen entities)
|
||||||
|
|
||||||
:else
|
(utils/intersects? (:fullscreen entities) [x y])
|
||||||
nil))))
|
(utils/toggle-fullscreen!)
|
||||||
|
|
||||||
|
:else
|
||||||
|
nil))))
|
||||||
|
|
||||||
|
|
||||||
:on-resize (fn [{:keys [viewport width height]} [entities]]
|
:on-resize (fn [{:keys [viewport width height]} [entities]]
|
||||||
|
|||||||
Reference in New Issue
Block a user