diff --git a/desktop/resources/behindhouse/background.png b/desktop/resources/behindhouse/background.png index d0122de2..e8b938ac 100644 Binary files a/desktop/resources/behindhouse/background.png and b/desktop/resources/behindhouse/background.png differ diff --git a/desktop/resources/behindhouse/fg.png b/desktop/resources/behindhouse/fg.png new file mode 100644 index 00000000..1d54cb4a Binary files /dev/null and b/desktop/resources/behindhouse/fg.png differ diff --git a/desktop/resources/behindhouse/fg2.png b/desktop/resources/behindhouse/fg2.png new file mode 100644 index 00000000..5eddc452 Binary files /dev/null and b/desktop/resources/behindhouse/fg2.png differ diff --git a/desktop/resources/behindhouse/fgleft.png b/desktop/resources/behindhouse/fgleft.png new file mode 100644 index 00000000..47ceaef3 Binary files /dev/null and b/desktop/resources/behindhouse/fgleft.png differ diff --git a/desktop/resources/inside-antique/background.png b/desktop/resources/inside-antique/background.png index c53d73d6..bbcf4fdd 100644 Binary files a/desktop/resources/inside-antique/background.png and b/desktop/resources/inside-antique/background.png differ diff --git a/desktop/resources/inside-antique/fg.png b/desktop/resources/inside-antique/fg.png new file mode 100644 index 00000000..624e78b7 Binary files /dev/null and b/desktop/resources/inside-antique/fg.png differ diff --git a/desktop/resources/inside-cafeteria/background.png b/desktop/resources/inside-cafeteria/background.png index 7049c405..5ca1ed6d 100644 Binary files a/desktop/resources/inside-cafeteria/background.png and b/desktop/resources/inside-cafeteria/background.png differ diff --git a/desktop/resources/inside-cafeteria/fg.png b/desktop/resources/inside-cafeteria/fg.png new file mode 100644 index 00000000..3bd53b64 Binary files /dev/null and b/desktop/resources/inside-cafeteria/fg.png differ diff --git a/desktop/resources/inside-castle/background.png b/desktop/resources/inside-castle/background.png index 21dbbe24..e9622cdf 100644 Binary files a/desktop/resources/inside-castle/background.png and b/desktop/resources/inside-castle/background.png differ diff --git a/desktop/resources/inside-castle/roof.png b/desktop/resources/inside-castle/roof.png new file mode 100644 index 00000000..3b8ad0a2 Binary files /dev/null and b/desktop/resources/inside-castle/roof.png differ diff --git a/desktop/resources/outsidehouse/background.png b/desktop/resources/outsidehouse/background.png index 11da2d7d..2a58e840 100644 Binary files a/desktop/resources/outsidehouse/background.png and b/desktop/resources/outsidehouse/background.png differ diff --git a/desktop/resources/outsidehouse/fg.png b/desktop/resources/outsidehouse/fg.png new file mode 100644 index 00000000..332c4bb6 Binary files /dev/null and b/desktop/resources/outsidehouse/fg.png differ diff --git a/desktop/resources/outsidehouse/fgtest.png b/desktop/resources/outsidehouse/fgtest.png new file mode 100644 index 00000000..cc57e8bc Binary files /dev/null and b/desktop/resources/outsidehouse/fgtest.png differ diff --git a/desktop/src-common/advent/actions.clj b/desktop/src-common/advent/actions.clj index f47d526e..7b1144e0 100644 --- a/desktop/src-common/advent/actions.clj +++ b/desktop/src-common/advent/actions.clj @@ -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])) diff --git a/desktop/src-common/advent/screens/rooms/behind_house.clj b/desktop/src-common/advent/screens/rooms/behind_house.clj index 0b3743c6..f16ff518 100644 --- a/desktop/src-common/advent/screens/rooms/behind_house.clj +++ b/desktop/src-common/advent/screens/rooms/behind_house.clj @@ -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)]} diff --git a/desktop/src-common/advent/screens/rooms/inside_antique.clj b/desktop/src-common/advent/screens/rooms/inside_antique.clj index 577ced73..26794839 100644 --- a/desktop/src-common/advent/screens/rooms/inside_antique.clj +++ b/desktop/src-common/advent/screens/rooms/inside_antique.clj @@ -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 diff --git a/desktop/src-common/advent/screens/rooms/inside_cafeteria.clj b/desktop/src-common/advent/screens/rooms/inside_cafeteria.clj index c607cbdb..8c610610 100644 --- a/desktop/src-common/advent/screens/rooms/inside_cafeteria.clj +++ b/desktop/src-common/advent/screens/rooms/inside_cafeteria.clj @@ -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 diff --git a/desktop/src-common/advent/screens/rooms/inside_castle.clj b/desktop/src-common/advent/screens/rooms/inside_castle.clj index d70f6003..6a5e1a92 100644 --- a/desktop/src-common/advent/screens/rooms/inside_castle.clj +++ b/desktop/src-common/advent/screens/rooms/inside_castle.clj @@ -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") diff --git a/desktop/src-common/advent/screens/rooms/outside_castle.clj b/desktop/src-common/advent/screens/rooms/outside_castle.clj index a66af65e..cd5f83ce 100644 --- a/desktop/src-common/advent/screens/rooms/outside_castle.clj +++ b/desktop/src-common/advent/screens/rooms/outside_castle.clj @@ -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 diff --git a/desktop/src-common/advent/screens/rooms/outside_house.clj b/desktop/src-common/advent/screens/rooms/outside_house.clj index 6332d116..a5a48f8e 100644 --- a/desktop/src-common/advent/screens/rooms/outside_house.clj +++ b/desktop/src-common/advent/screens/rooms/outside_house.clj @@ -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) diff --git a/desktop/src-common/advent/screens/scene.clj b/desktop/src-common/advent/screens/scene.clj index f09e8875..da61f7d7 100644 --- a/desktop/src-common/advent/screens/scene.clj +++ b/desktop/src-common/advent/screens/scene.clj @@ -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]]