parallax scrolling looks awesome.
This commit is contained in:
@@ -443,6 +443,7 @@
|
||||
parallax-view (Matrix4.)
|
||||
parallax-combined (Matrix4.)]
|
||||
(.update camera)
|
||||
|
||||
(.set tmp (.position camera))
|
||||
(set! (.x tmp) (* (.x tmp) 1.5))
|
||||
(set! (.y tmp) (* (.y tmp) 1.5))
|
||||
@@ -453,11 +454,15 @@
|
||||
(.set parallax-combined (.projection camera))
|
||||
(Matrix4/mul (.val parallax-combined) (.val parallax-view))
|
||||
|
||||
|
||||
(let [^Batch batch (.getBatch renderer)]
|
||||
|
||||
(.begin batch)
|
||||
(.setProjectionMatrix batch parallax-combined)
|
||||
(entities/draw! (:tex foreground) screen batch)
|
||||
|
||||
(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))
|
||||
(.end batch))))
|
||||
|
||||
|
||||
@@ -527,7 +532,8 @@
|
||||
:override nil
|
||||
:last-pos [0 0]}
|
||||
:foreground {:object nil
|
||||
:tex (assoc (texture "outsidehouse/fg1.png") :x 75 :y 57 :baseline 1000)}
|
||||
: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
|
||||
|
||||
Reference in New Issue
Block a user