From 1733fa81c7fcd230249b2cb9d6383d1cfa39a8e1 Mon Sep 17 00:00:00 2001 From: Remington Covert Date: Sun, 1 Mar 2015 17:33:23 -0800 Subject: [PATCH] moving everyone. --- desktop/src-common/advent/screens/scene.clj | 25 +++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/desktop/src-common/advent/screens/scene.clj b/desktop/src-common/advent/screens/scene.clj index 1a30f7db..01671781 100644 --- a/desktop/src-common/advent/screens/scene.clj +++ b/desktop/src-common/advent/screens/scene.clj @@ -36,6 +36,7 @@ [clojure.core.async :refer [put! ! chan go thread take! alts!!]]) (:import [com.badlogic.gdx.graphics Pixmap Pixmap$Filter Texture Texture$TextureFilter GL20 GL30] [com.badlogic.gdx.graphics.g2d TextureRegion Animation] + [com.badlogic.gdx.math Vector3 Matrix4] [com.badlogic.gdx.utils.viewport FitViewport] [com.badlogic.gdx.scenes.scene2d Actor Stage] [java.lang Object] @@ -431,6 +432,27 @@ (update-fn screen entities) entities)) +(defn render-foreground [{:keys [camera renderer] :as screen} foreground] + (let [tmp (Vector3.) + tmp2 (Vector3.) + parallax-view (Matrix4.) + parallax-combined (Matrix4.)] + (.update camera) + (.set tmp (.position camera)) + (set! (.x tmp) (* (.x tmp) 2)) + (set! (.y tmp) (* (.y tmp) 2)) + (.setToLookAt parallax-view tmp (-> tmp2 + (.set tmp) + (.add (.direction camera)) + ( .up camera))) + (.set parallax-combined (.projection camera)) + (Matrix4/mul (.val parallax-combined) (.val parallax-view)) + (.setProjectionMatrix camera parallax-combined) + (let [batch (.getBatch renderer)] + (.begin batch) + (draw! (:tex foreground) screen batch) + (.end batch)))) + (defscreen scene :on-timer @@ -497,6 +519,8 @@ :last :main :override nil :last-pos [0 0]} + :foreground {:object nil + :tex (assoc (texture "outsidehouse/foreground.png") :x 0 :y 0 :baseline 1000)} :all-items (assoc items/items :object nil) :started? {:value false @@ -567,6 +591,7 @@ (when m (music! m :set-volume (get-in entities [:volume :value])))) (render! screen (sort-by :baseline all-entities)) + (render-foreground screen (:foreground entities)) entities)) :on-resize (fn [{:keys [viewport width height]} [entities]]