hourglass, for sure, between title and game.

This commit is contained in:
Bryce Covert
2015-08-14 08:24:46 -07:00
parent 848a07721b
commit de6874f27d
3 changed files with 117 additions and 97 deletions

View File

@@ -54,3 +54,5 @@
+Click on active item, move off, cursor is still active
+ Click on cauldron should tell you what you need to add
+can walk to top corner in house screen

View File

@@ -629,15 +629,16 @@ void main()
entities))
(defn update-cursor [screen {{:keys [current override last active was-active]} :cursor :as entities}]
(let [new-current (or override current)]
(when-not (and (= new-current
last)
(= active was-active))
(when (= :last :hourglass)
(println new-current))
(let [image-path (if active "cursor_light.png" "cursor.png")]
(input! :set-cursor-image (utils/cursor image-path (or (:cursor new-current) new-current)) 0 0)))
(assoc-in entities [:cursor :last] new-current)))
(if (= 0.0 (get-in entities [:fade :opacity]))
(let [new-current (or override current)]
(when-not (and (= new-current
last)
(= active was-active))
(let [image-path (if active "cursor_light.png" "cursor.png")]
(input! :set-cursor-image (utils/cursor image-path (or (:cursor new-current) new-current)) 0 0)))
(assoc-in entities [:cursor :last] new-current))
entities))
@@ -795,8 +796,7 @@ void main()
(let [screen (assoc screen :total-time 0)]
(let [[cam] (utils/setup-viewport screen 320 240)]
(set! (. cam zoom) 0.95)
(let [_ (input! :set-cursor-image (utils/cursor "cursor.png" :main) 0 0)
shader (ShaderProgram. v-shader pix-shader)
(let [shader (ShaderProgram. v-shader pix-shader)
_ (update! screen :shader shader)
rooms {:inside-house (rooms.inside-house/make screen)
:inside-stash (rooms.inside-stash/make screen)
@@ -835,6 +835,8 @@ void main()
:sprite utils/default-night-merge-sprite
:none {}}
:closing? {:object nil
:value false}
:sounds {:blink (sound "blink-other.ogg")
:object nil}
:fade {:object nil
@@ -857,8 +859,8 @@ void main()
:value nil}
:cursor {:id "cursor"
:current :main
:last :main
:override nil
:last nil
:override :hourglass
:last-pos [0 0]}
:all-items (assoc items/items :object nil)
@@ -882,73 +884,83 @@ void main()
:on-render
(fn [{:keys [camera] :as screen} [entities]]
(clear!)
(let [entities (fade-in-first-time-if-necessary screen entities)
entities (utils/apply-tweens screen entities (:tweens entities))
entities (update-cursor screen entities)
entities (update-from-script screen entities)
entities (update-from-room 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 (update-in entities [:room :entities] (fn [entities]
(into entities
(for [[id entity] entities]
(if (:anim entity)
[id (animate entity screen)]
[id entity])))))
entities (update-in entities [:room :entities] (fn [entities]
(into entities
(for [[id entity] entities]
(if (:update-fn entity)
[id ((:update-fn entity) screen entities entity)]
[id entity])))))
entities (if (and (not (get-in entities [:cam :paused?]))
(nil? (get-in entities [:tweens :cam-x]))
(= 1 (rand-int 20)))
(if (= (rand-int 2) 1)
(actions/pan-to screen entities
(get-in entities [:room :entities :ego :x])
(get-in entities [:room :entities :ego :y])
(constantly (get-in entities [:room :entities :ego :scale-x]))
tween/ease-in-out-quadratic
5.0)
(actions/pan-to screen entities
(+ (get-in entities [:cam :x] 0)
(- 10 (rand-int 20)))
(+ (get-in entities [:cam :y] 0)
(- 10 (rand-int 20)))
(constantly (get-in entities [:room :entities :ego :scale-x]))
tween/ease-in-out-quadratic
5.0))
entities)
layers (get-layers entities)
all-entities (concat (vals entities) layers (vals (get-in entities [:room :entities])))]
(screen! talking-screen :on-update-camera :scene-viewport (:viewport screen) :scene-camera (:camera screen))
(screen! fade-screen :update-fade :opacity (get-in entities [:fade :opacity]))
(when true #_(not (get-in entities [:cam :paused?]))
(set! (. camera zoom) (:zoom (:cam entities)))
(set! (.. camera position x) (:x (:cam entities) 160.0))
(set! (.. camera position y) (:y (:cam entities) 120.0)))
(let [entities (utils/update-override screen entities)]
(when (= (get-in entities [:fade :opacity])
0.0)
(play-key-sounds entities))
(doseq [m (vals (get-in entities [:musics]))]
(when m
(music! m :set-volume (utils/current-music-volume (get-in entities [:volume :value])))))
(doseq [e (sort-by :baseline all-entities)]
(if (get-in entities [:closing? :value])
(let [entities (utils/apply-tweens screen entities (:tweens entities))
layers (get-layers entities)
all-entities (concat (vals entities) layers (vals (get-in entities [:room :entities])))]
(screen! fade-screen :update-fade :opacity (get-in entities [:fade :opacity]))
#_(doseq [e (sort-by :baseline all-entities)]
(if (:parallax e)
(render-parallax screen (get-rendered entities e))
(render! screen [(get-rendered entities e)])))
entities)))
(render! screen [(get-rendered entities e)]))))
(let [entities (fade-in-first-time-if-necessary screen entities)
entities (utils/apply-tweens screen entities (:tweens entities))
entities (update-cursor screen entities)
entities (update-from-script screen entities)
entities (update-from-room 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 (update-in entities [:room :entities] (fn [entities]
(into entities
(for [[id entity] entities]
(if (:anim entity)
[id (animate entity screen)]
[id entity])))))
entities (update-in entities [:room :entities] (fn [entities]
(into entities
(for [[id entity] entities]
(if (:update-fn entity)
[id ((:update-fn entity) screen entities entity)]
[id entity])))))
entities (if (and (not (get-in entities [:cam :paused?]))
(nil? (get-in entities [:tweens :cam-x]))
(= 1 (rand-int 20)))
(if (= (rand-int 2) 1)
(actions/pan-to screen entities
(get-in entities [:room :entities :ego :x])
(get-in entities [:room :entities :ego :y])
(constantly (get-in entities [:room :entities :ego :scale-x]))
tween/ease-in-out-quadratic
5.0)
(actions/pan-to screen entities
(+ (get-in entities [:cam :x] 0)
(- 10 (rand-int 20)))
(+ (get-in entities [:cam :y] 0)
(- 10 (rand-int 20)))
(constantly (get-in entities [:room :entities :ego :scale-x]))
tween/ease-in-out-quadratic
5.0))
entities)
layers (get-layers entities)
all-entities (concat (vals entities) layers (vals (get-in entities [:room :entities])))]
(clear!)
(screen! talking-screen :on-update-camera :scene-viewport (:viewport screen) :scene-camera (:camera screen))
(screen! fade-screen :update-fade :opacity (get-in entities [:fade :opacity]))
(when true #_(not (get-in entities [:cam :paused?]))
(set! (. camera zoom) (:zoom (:cam entities)))
(set! (.. camera position x) (:x (:cam entities) 160.0))
(set! (.. camera position y) (:y (:cam entities) 120.0)))
(let [entities (utils/update-override screen entities)]
(when (= (get-in entities [:fade :opacity])
0.0)
(play-key-sounds entities))
(doseq [m (vals (get-in entities [:musics]))]
(when m
(music! m :set-volume (utils/current-music-volume (get-in entities [:volume :value])))))
(doseq [e (sort-by :baseline all-entities)]
(if (:parallax e)
(render-parallax screen (get-rendered entities e))
(render! screen [(get-rendered entities e)])))
entities))))
:on-resize (fn [{:keys [viewport width height]} [entities]]
(.update viewport width height))
@@ -995,14 +1007,14 @@ void main()
(click-inventory screen entities))
:on-menu (fn [screen [entities]]
(when-not (get-in entities [:tweens :fade-out])
(input! :set-cursor-image (utils/cursor "cursor.png" :hourglass) 0 0)
(-> entities
(assoc-in [:cursor :override] nil)
(assoc-in [:closing? :value] true)
(assoc-in [:tweens :fade-out-music]
(tween/tween :fade-out-music screen [:volume :value] 1.0 0.0 1.0))
(assoc-in [:tweens :fade-out]
(tween/tween :fade-out screen [:fade :opacity] 0.0 1.0 1.0
:finish #(do (.clear @(resolve 'advent.core/am))
(input! :set-cursor-image (utils/cursor "cursor.png" :main) 0 0)
(set-screen! @(resolve 'advent.core/advent) @(resolve 'advent.screens.title/title-screen))
%))))))

View File

@@ -92,6 +92,7 @@
(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)
{:background (assoc (texture "title/background.png" ) :x 0 :y 0 :scale-x 4 :scale-y 4 :origin-x 0 :origin-y 0)
:cloud-background (assoc (texture "title/clouds.png" ) :x 0 :y 0 :scale-x 4 :scale-y 4 :origin-x 0 :origin-y 0)
@@ -148,7 +149,10 @@
:fullscreen fullscreen
:copyright copyright
:tweens {:fade-in (tween/tween :fade-in screen [:fade :opacity] 1.0 0.0 1.0
:finish #(do (utils/play-sound (:music %)) %)
:finish #(do
(input! :set-cursor-image (utils/cursor "cursor.png" :main) 0 0)
(utils/play-sound (:music %)) %)
:ease tween/ease-in-quadratic)}}))
:on-render
@@ -188,24 +192,26 @@
(let [[x y] (utils/unproject screen)]
(cond
(utils/intersects? (:start-playing entities) [x y])
(-> 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/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)))
(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/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])
(-> 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)))
(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])
(if (.isFullscreen Gdx/graphics)