parallax scrolling used elsewhere.

This commit is contained in:
2015-03-02 12:32:33 -08:00
parent 2c2507febf
commit d15b0983f4
21 changed files with 37 additions and 23 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 21 KiB

After

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 50 KiB

After

Width:  |  Height:  |  Size: 51 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 27 KiB

After

Width:  |  Height:  |  Size: 28 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 21 KiB

After

Width:  |  Height:  |  Size: 20 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 29 KiB

After

Width:  |  Height:  |  Size: 21 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB

View File

@@ -97,11 +97,11 @@
0.07)
current-zoom
target-zoom)
target-x (min (- 320 (* 160.0 target-zoom))
(max (* 160.0 target-zoom)
target-x (min (- 320 (* 160.0 target-zoom ))
(max (* 160.0 target-zoom )
x))
target-y (min (- 240 (* 120.0 target-zoom))
(max (* 120.0 target-zoom)
target-y (min (- 240 (* 120.0 target-zoom ))
(max (* 120.0 target-zoom )
y))]
(if (or (not= target-x (get-in entities [:cam :x]))
(not= target-y (get-in entities [:cam :y]))

View File

@@ -47,7 +47,9 @@
:ego "It's hard to make out from this angle.")))}}
:layers {:day [(assoc (texture "behindhouse/background.png") :x 0 :y 0 :baseline 0)
(assoc (texture "behindhouse/house.png") :x 0 :y 0 :baseline 122)
(assoc (texture "behindhouse/brush.png") :x 0 :y 0 :baseline 240)]
(assoc (texture "behindhouse/brush.png") :x 0 :y 0 :baseline 240)
(assoc (texture "behindhouse/fgleft.png") :x -10 :y 0 :baseline 240 :parallax 1.5)
(assoc (texture "behindhouse/fg2.png") :x (- 320 122) :y 0 :baseline 240 :parallax 1.5)]
:night [(assoc (texture "behindhouse/background-dark.png") :x 0 :y 0 :baseline 0)
(assoc (texture "behindhouse/house-dark.png") :x 0 :y 0 :baseline 122)
(assoc (texture "behindhouse/brush-dark.png") :x 0 :y 0 :baseline 240)]}

View File

@@ -166,7 +166,8 @@
:ego "It's a tapestry of Rupert the Lion!"
:ego "He's the town of Remington's mascot."))}
}
:layers [(assoc (texture "inside-antique/background.png") :x 0 :y 0 :baseline 0)]
:layers [(assoc (texture "inside-antique/background.png") :x 0 :y 0 :baseline 0)
(assoc (texture "inside-antique/fg.png") :x 0 :y 0 :baseline 320 :parallax 1.5)]
:entities {:shopkeep (actions/start-animation screen (assoc (animation->texture screen shopkeep-stand) :x 148 :y 122 :baseline 112
:stand shopkeep-stand
:scale-x 1.6

View File

@@ -164,7 +164,8 @@
(actions/walk-to entities :ego [126 80]))
:cursor :right}
}
:layers [(assoc (texture "inside-cafeteria/background.png") :x 0 :y 0 :baseline 0)]
:layers [(assoc (texture "inside-cafeteria/background.png") :x 0 :y 0 :baseline 0)
(assoc (texture "inside-cafeteria/fg.png") :x 10 :y 0 :scale-x 1.1 :scale-y 1.0 :baseline 320 :parallax 1.5)]
:entities {
:warriors (actions/start-animation screen (assoc (animation->texture screen warriors-stand) :x 8 :y 19 :baseline 180

View File

@@ -284,7 +284,8 @@
(actions/do-dialogue entities
:ego "That's Georgia McGorgeous' house."
:ego "One day, when I'm a knight, I'll ask her to be my girlfriend."))}}
:layers {:day [(assoc (texture "inside-castle/background.png") :x 0 :y 0 :baseline 0)]
:layers {:day [(assoc (texture "inside-castle/background.png") :x 0 :y 0 :baseline 0)
(assoc (texture "inside-castle/roof.png") :x (- 320 57) :y 0 :baseline 240 :parallax 1.5)]
:night [(assoc (texture "inside-castle/background-dark.png") :x 0 :y 0 :baseline 0)]
:sunrise [(assoc (texture "inside-castle/background-sunrise.png") :x 0 :y 0 :baseline 0)]}
:blackout (assoc (texture "black.png")

View File

@@ -290,7 +290,8 @@
(actions/play-animation entities :ego :squat)
(actions/talk entities :ego "No one will notice one missing.")
(actions/give entities :carrot))))}}
:layers {:day [(assoc (texture "outside-castle/background.png") :x 0 :y 0 :baseline 0)]
:layers {:day [(assoc (texture "outside-castle/background.png") :x 0 :y 0 :baseline 0)
]
:night [(assoc (texture "outside-castle/background-dark.png") :x 0 :y 0 :baseline 0)]
:sunrise [(assoc (texture "outside-castle/background-sunrise.png") :x 0 :y 0 :baseline 0)]}
:entities {:peddler (actions/start-animation screen

View File

@@ -312,7 +312,11 @@
(assoc (texture "outsidehouse/house.png") :x 0 :y 0 :baseline 122)
(assoc (texture "outsidehouse/fence.png") :x 0 :y 0 :baseline 93)
(assoc (texture "outsidehouse/background-trees.png") :x 0 :y 0 :baseline 44)]
(assoc (texture "outsidehouse/background-trees.png") :x 0 :y 0 :baseline 44)
(assoc (texture "outsidehouse/fg1.png") :x 0 :y 0 :baseline 1000 :parallax 1.5)
(assoc (texture "outsidehouse/fg2.png") :x (- 320 55) :y 0 :baseline 1000 :parallax 1.5)
#_(assoc (texture "outsidehouse/fg1.png") :x 0 :y 0 :baseline 1000 :parallax 1.5)
#_(assoc (texture "outsidehouse/fg2.png") :x (- 320 30) :y 0 :baseline 1000 :parallax 1.5)]
:night [(assoc (texture "outsidehouse/background-dark.png") :x 0 :y 0 :baseline 0)
(assoc (texture "outsidehouse/house-dark.png") :x 0 :y 0 :baseline 122)
(assoc (texture "outsidehouse/fence-dark.png") :x 0 :y 0 :baseline 93)

View File

@@ -436,8 +436,8 @@
(update-fn screen entities)
entities))
(defn render-foreground [{:keys [^OrthographicCamera camera ^Stage renderer] :as screen} foreground]
#_(println camera)
(defn render-parallax [{:keys [^OrthographicCamera camera ^Stage renderer] :as screen} {:keys [parallax] :as e }]
(let [tmp (Vector3.)
tmp2 (Vector3.)
parallax-view (Matrix4.)
@@ -445,8 +445,8 @@
(.update camera)
(.set tmp (.position camera))
(set! (.x tmp) (* (.x tmp) 1.5))
(set! (.y tmp) (* (.y tmp) 1.5))
(set! (.x tmp) (* (.x tmp) parallax))
(set! (.y tmp) (* (.y tmp) parallax))
(.setToLookAt parallax-view tmp (-> tmp2
(.set tmp)
(.add (.direction camera)))
@@ -460,9 +460,12 @@
(.begin batch)
(.setProjectionMatrix batch parallax-combined)
(doseq [e (:texes foreground)]
(entities/draw! (assoc e :x (+ (/ (:x e) (.zoom camera)) (- 240 (/ 160 (.zoom camera)) ))
:y (+ (/ (:y e) (.zoom camera)) (- 180 (/ 120 (.zoom camera))))) screen batch))
(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)
(.end batch))))
@@ -493,7 +496,7 @@
:outside-castle (rooms.outside-castle/make screen)}
entities {:rooms rooms
:step-particles (assoc (particle-effect "ego/step") :x 100 :y 100 :baseline 241)
:cam {:zoom 0.95
:cam {:zoom 0.95
:object nil}
:musics {:object nil
:inside-antique (utils/make-music "inside-antique.ogg")
@@ -531,9 +534,6 @@
:last :main
:override nil
:last-pos [0 0]}
:foreground {:object nil
:texes [(assoc (texture "outsidehouse/fg1.png") :x 0 :y 0 :baseline 1000)
(assoc (texture "outsidehouse/fg2.png") :x (- 320 59) :y 0 :baseline 1000)]}
:all-items (assoc items/items :object nil)
:started? {:value false
@@ -603,8 +603,12 @@
(doseq [m (vals (get-in entities [:musics]))]
(when m
(music! m :set-volume (get-in entities [:volume :value]))))
(render! screen (sort-by :baseline all-entities))
(render-foreground screen (:foreground entities))
(doseq [e (sort-by :baseline all-entities)]
(if (:parallax e)
(render-parallax screen e)
(render! screen [e])))
entities))
:on-resize (fn [{:keys [viewport width height]} [entities]]