started on save menu.

This commit is contained in:
Bryce Covert
2015-09-25 21:59:47 -07:00
parent a75aa068b6
commit edd7e59fdd

View File

@@ -27,7 +27,8 @@
(color 1.0 0.3 0.3 1.0)))
(defn style-label [e font mouse-pos]
(label! e :set-style (style :label font (get-color e mouse-pos)))
(when (:interactable e)
(label! e :set-style (style :label font (get-color e mouse-pos))))
e)
(defn style-slider [s mouse-pos]
@@ -129,6 +130,41 @@
(defn stack-y [label base index]
(assoc label :y (- 280 (* 32 index))))
(defn main-menu []
{:start-playing (-> (make-label (quest-label))
(stack-y 280 0)
(assoc :z 8
:interactable true))
:music-label (-> (make-label "Music" (color :white))
(stack-y 280 1)
(assoc :z 8))
:music-volume-slider (-> (make-slider (:music-volume @utils/settings))
center
(stack-y 280 2)
(assoc :z 8))
:sound-label (-> (make-label "FX" (color :white))
(stack-y 280 3)
(assoc :z 8))
:sound-volume-slider (-> (make-slider (:sound-volume @utils/settings))
center
(stack-y 280 4)
(assoc :z 8))
:fullscreen (-> (make-label "Fullscreen")
(stack-y 280 5)
(assoc :z 8 :interactable true))
:quit (-> (make-label "End quest")
(stack-y 280 6)
(assoc :z 8 :interactable true))})
(defn saves-menu []
{"Where we left off" (-> (make-label "Where we left off")
(stack-y 280 0)
(assoc :z 8))})
(defscreen title-screen
:on-show
(fn [screen entities]
@@ -140,69 +176,55 @@
(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 :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 :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 :z 6)
:fade (assoc (utils/get-texture "black.png")
:scale-x 80
:scale-y 80
:opacity 1.0
:origin-x 0
:origin-y 0
:z 100)
:flying-ego (assoc (utils/get-texture "ego/flying.png")
:left (flip (utils/get-texture "ego/flying.png"))
:right (utils/get-texture "ego/flying.png")
:scale-x 5
:scale-y 5
:origin-x 2
: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)
:x 450
: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
: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)
:z 3)
: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)
(let [entities {: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 :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 :z 6)
:fade (assoc (utils/get-texture "black.png")
:scale-x 80
:scale-y 80
:opacity 1.0
:origin-x 0
:origin-y 0
:z 100)
:flying-ego (assoc (utils/get-texture "ego/flying.png")
:left (flip (utils/get-texture "ego/flying.png"))
:right (utils/get-texture "ego/flying.png")
:scale-x 5
:scale-y 5
:origin-x 2
: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)
:x 450
: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
: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)
:z 3)
: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 (-> (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
:z 7)
center)
:start-playing (-> (make-label (quest-label))
(stack-y 280 0))
:toolbox (-> (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
:z 7)
center)
:main-menu (main-menu)
:font font
:music music
:volume 1.0
:copyright (make-label "DEMO - Copyright Bryce Covert - Not for distribution")
:tweens {:fade-in (tween/tween :fade-in screen [:fade :opacity] 1.0 0.0 1.0
:finish #(do
:music-label (-> (make-label "Music" (color :white))
(stack-y 280 1))
:music-volume-slider (-> (make-slider (:music-volume @utils/settings))
center
(stack-y 280 2))
:sound-label (-> (make-label "FX" (color :white))
(stack-y 280 3))
:sound-volume-slider (-> (make-slider (:sound-volume @utils/settings))
center
(stack-y 280 4))
:fullscreen (-> (make-label "Fullscreen")
(stack-y 280 5))
:quit (-> (make-label "End quest")
(stack-y 280 6))
:font font
:music music
:volume 1.0
:copyright (make-label "DEMO - Copyright Bryce Covert - Not for distribution")
:tweens {:fade-in (tween/tween :fade-in screen [:fade :opacity] 1.0 0.0 1.0
:finish #(do
(input! :set-cursor-image (utils/cursor "cursor.png" :main) 0 0)
(utils/play-sound (:music %)) %)
:ease tween/ease-in-quadratic)}}))
(input! :set-cursor-image (utils/cursor "cursor.png" :main) 0 0)
(utils/play-sound (:music %)) %)
:ease tween/ease-in-quadratic)}}
]
(merge entities (:main-menu entities)))))
:on-render
(fn [{:keys [^FitViewport viewport] :as screen} [entities]]
@@ -211,11 +233,12 @@
(let [entities (utils/apply-tweens screen entities (:tweens entities))
entities (fly-ego screen entities)
entities (fly-balloon screen entities)
entities (update-in entities [:balloon] merge (animation->texture screen (:anim (:balloon entities))))
]
(label! (:fullscreen entities) :set-text (if (.isFullscreen Gdx/graphics)
"Fullscreen"
"Windowed"))
entities (update-in entities [:balloon] merge (animation->texture screen (:anim (:balloon entities))))]
(when (:fullscreen entities)
(label! (:fullscreen entities) :set-text (if (.isFullscreen Gdx/graphics)
"Fullscreen"
"Windowed")))
(music! (:music entities) :set-volume (utils/current-music-volume (:volume entities)))
(render! screen (sort-by :z (filter :object (vals entities))) )
@@ -226,12 +249,13 @@
:on-mouse-moved (fn [screen [entities]]
(let [[x y] (utils/unproject screen)]
(style-label (:start-playing entities) (get-in entities [:font]) [x y])
(style-label (:fullscreen entities) (get-in entities [:font]) [x y])
(style-label (:quit entities) (get-in entities [:font]) [x y])
(style-slider (:music-volume-slider entities) [x y])
(style-slider (:sound-volume-slider entities) [x y])
entities))
(doseq [entity (vals entities)
:when (:object entity)]
(cond (label? entity)
(style-label entity (get-in entities [:font]) [x y])
(slider? entity)
(style-slider entity [x y])))))
:on-key-up
(fn [screen entities]
(when (= (key-code :escape) (:key screen))