hopefully less memory.

This commit is contained in:
Bryce Covert
2016-08-08 13:20:25 -07:00
parent 8e54698f54
commit 6eda69a1b8
2 changed files with 37 additions and 33 deletions

View File

@@ -33,7 +33,7 @@
[slamhound "1.5.5"] [slamhound "1.5.5"]
[org.clojure/data.csv "0.1.3"]] [org.clojure/data.csv "0.1.3"]]
:warn-on-reflection true} #_#_:warn-on-reflection true}
:app-store { :app-store {
:source-paths ["src" "src-common" "src-dev"] :source-paths ["src" "src-common" "src-dev"]
:jvm-opts ["-Dapp-store=true" "-Dno-steam=true"] :jvm-opts ["-Dapp-store=true" "-Dno-steam=true"]

View File

@@ -53,6 +53,8 @@
VertexAttributes$Usage] VertexAttributes$Usage]
[com.badlogic.gdx.scenes.scene2d Actor Stage])) [com.badlogic.gdx.scenes.scene2d Actor Stage]))
(set! *unchecked-math* :warn-on-boxed)
(declare hud) (declare hud)
(declare get-selected-inventory-item) (declare get-selected-inventory-item)
@@ -712,7 +714,7 @@ void main ()
:poke (utils/flip poke) :poke (utils/flip poke)
:whistle (utils/flip whistle) :whistle (utils/flip whistle)
} }
:baseline (- 240 (last start-pos)) :baseline (- 240 (double (last start-pos)))
:facing :right :facing :right
:night-profile :sprite :night-profile :sprite
:origin-x 9 :origin-x 9
@@ -745,9 +747,9 @@ void main ()
:talk-color (color 0.6 1.0 1.0 1.0) :talk-color (color 0.6 1.0 1.0 1.0)
:stand-override nil :stand-override nil
:mouse-in? (fn [entities x y] :mouse-in? (fn [entities x y]
(let [{entity-x :x entity-y :y ^TextureRegion region :object scale :scale-x} (get-in entities [:room :entities :ego]) (let [{^double entity-x :x ^double entity-y :y ^TextureRegion region :object scale :scale-x} (get-in entities [:room :entities :ego])
half-width (/ (* (.getRegionWidth region) (or scale 1.0)) 2) half-width (double (/ (* (.getRegionWidth region) (double (or scale 1.0))) 2))
height (* (.getRegionHeight region) (or scale 1.0))] height (double (* (.getRegionHeight region) (double (or scale 1.0))))]
((zone/box (- entity-x half-width) entity-y (+ entity-x half-width) (+ entity-y height)) x y))) ((zone/box (- entity-x half-width) entity-y (+ entity-x half-width) (+ entity-y height)) x y)))
:get-script get-ego-script :get-script get-ego-script
@@ -996,7 +998,7 @@ void main ()
(update-in entities [:current-sounds :value] (update-in entities [:current-sounds :value]
(fn [sounds] (fn [sounds]
(filter #(or (= :loop (:type %)) (filter #(or (= :loop (:type %))
(> (:ends-at %) (:total-time screen))) (> ^double (:ends-at %) ^double (:total-time screen)))
sounds)))) sounds))))
(defn update-from-room [screen entities] (defn update-from-room [screen entities]
@@ -1004,7 +1006,7 @@ void main ()
(update-fn screen entities) (update-fn screen entities)
entities)) entities))
(defn render-parallax [{:keys [^OrthographicCamera camera ^Stage renderer ^ShaderProgram shader] :as screen} {:keys [parallax ^float multiply-amount ^float hue-amount] :as e }] (defn render-parallax [{:keys [^OrthographicCamera camera ^Stage renderer ^ShaderProgram shader] :as screen} {:keys [^double parallax ^float multiply-amount ^float hue-amount] :as e }]
(let [tmp (Vector3.) (let [tmp (Vector3.)
tmp2 (Vector3.) tmp2 (Vector3.)
@@ -1013,8 +1015,8 @@ void main ()
(.update camera) (.update camera)
(.set tmp (.position camera)) (.set tmp (.position camera))
(set! (.x tmp) (* (.x tmp) parallax)) (set! (.x tmp) (double (* (.x tmp) parallax)))
(set! (.y tmp) (* (.y tmp) parallax)) (set! (.y tmp) (double (* (.y tmp) parallax)))
(.setToLookAt parallax-view tmp (-> tmp2 (.setToLookAt parallax-view tmp (-> tmp2
(.set tmp) (.set tmp)
(.add (.direction camera))) (.add (.direction camera)))
@@ -1035,24 +1037,24 @@ void main ()
(.setColor batch (color (:r e 1.0) (:g e 1.0) (:b e 1.0) (:opacity e 1.0))) (.setColor batch (color (:r e 1.0) (:g e 1.0) (:b e 1.0) (:opacity e 1.0)))
(entities/draw! (assoc e :x (+ (/ (:x e) (.zoom camera)) (entities/draw! (assoc e :x (+ (/ ^double (:x e) (.zoom camera))
(- (* 320 parallax 0.5) (- (* 320 parallax 0.5)
(/ 160 (.zoom camera)) )) (/ 160 (.zoom camera)) ))
:y (+ (/ (:y e) (.zoom camera)) :y (+ (/ ^double (:y e) (.zoom camera))
(- (* 240 parallax 0.5) (- (* 240 parallax 0.5)
(/ 120 (.zoom camera))))) screen batch) (/ 120 (.zoom camera))))) screen batch)
(.setColor batch (color 1 1 1 1)) (.setColor batch (color 1 1 1 1))
(.end batch)))) (.end batch))))
(defn get-rendered [entities e] (defn get-rendered [entities {:keys [time ^double y ^double offset-y night-profile] :or {night-profile :default} :as e}]
(as-> e e (as-> e e
(merge e (merge e
(when (and (not= (:time e) (get-in entities [:state :time])) (when (and (not= time (get-in entities [:state :time]))
(#{:night :sunrise} (get-in entities [:state :time]))) (#{:night :sunrise} (get-in entities [:state :time])))
(assoc (get-in entities [:time-profiles (:night-profile e :default)]) (assoc (get-in entities [:time-profiles night-profile])
:time (get-in entities [:state :time])))) :time (get-in entities [:state :time]))))
(if (:offset-y e) (if offset-y
(assoc e :y (+ (:y e) (:offset-y e))) (assoc e :y (+ y offset-y))
e))) e)))
(defn mouse-moved [screen entities {:keys [input-x input-y] :as options}] (defn mouse-moved [screen entities {:keys [input-x input-y] :as options}]
@@ -1287,10 +1289,10 @@ void main ()
tween/ease-in-out-quadratic tween/ease-in-out-quadratic
5.0) 5.0)
(actions/pan-to screen entities (actions/pan-to screen entities
(+ (get-in entities [:cam :x] 0) (+ ^double (get-in entities [:cam :x] 0)
(- 10 (rand-int 20))) (- 10 ^double (rand-int 20)))
(+ (get-in entities [:cam :y] 0) (+ ^double (get-in entities [:cam :y] 0)
(- 10 (rand-int 20))) (- 10 ^double (rand-int 20)))
(constantly (get-in entities [:room :entities :ego :scale-x])) (constantly (get-in entities [:room :entities :ego :scale-x]))
tween/ease-in-out-quadratic tween/ease-in-out-quadratic
5.0)) 5.0))
@@ -1298,14 +1300,16 @@ void main ()
entities (grab-layers entities) entities (grab-layers entities)
update-room (comp update-room (fn [{:keys [anim update-fn] :as e}]
#(if (:anim %) (let [e (if (:anim e)
(animate % screen) (animate e screen)
%) e)
#(if (:update-fn %)
((:update-fn %) screen entities %) e (if update-fn
%) (update-fn screen entities e)
(partial get-rendered entities)) e)
e (get-rendered entities e)]
e))
entities (loop [entities entities entities (loop [entities entities
[[k e] & rest] (seq (get-in entities [:room :entities]))] [[k e] & rest] (seq (get-in entities [:room :entities]))]
(if k (if k
@@ -1542,7 +1546,7 @@ void main ()
(transition-done? [this screen entities] (transition-done? [this screen entities]
(animation! (get-in entities [:inventory :anim]) (animation! (get-in entities [:inventory :anim])
:is-animation-finished :is-animation-finished
(- (:total-time screen) (get-in entities [:inventory :anim-start]))))) (- ^double (:total-time screen) ^double (get-in entities [:inventory :anim-start])))))
(reify ITransition (reify ITransition
(start-transition [this screen entities] (start-transition [this screen entities]
@@ -1566,7 +1570,7 @@ void main ()
(transition-done? [this screen entities] (transition-done? [this screen entities]
(animation! (get-in entities [:inventory :anim]) (animation! (get-in entities [:inventory :anim])
:is-animation-finished :is-animation-finished
(- (:total-time screen) (get-in entities [:inventory :anim-start]))))) (- ^double (:total-time screen) ^double (get-in entities [:inventory :anim-start])))))
(reify ITransition (reify ITransition
(start-transition [this screen entities] (start-transition [this screen entities]
@@ -1633,7 +1637,7 @@ void main ()
(transition-done? [this screen entities] (transition-done? [this screen entities]
(animation! (get-in entities [:inventory :anim]) (animation! (get-in entities [:inventory :anim])
:is-animation-finished :is-animation-finished
(- (:total-time screen) (get-in entities [:inventory :anim-start]))))) (- ^double (:total-time screen) ^double (get-in entities [:inventory :anim-start])))))
(appear-transition state-data :show :out) (appear-transition state-data :show :out)
(reify ITransition (reify ITransition
@@ -1656,7 +1660,7 @@ void main ()
(transition-done? [this screen entities] (transition-done? [this screen entities]
(animation! (get-in entities [:inventory :anim]) (animation! (get-in entities [:inventory :anim])
:is-animation-finished :is-animation-finished
(- (:total-time screen) (get-in entities [:inventory :anim-start]))))) (- ^double (:total-time screen) ^double (get-in entities [:inventory :anim-start])))))
(reify ITransition (reify ITransition
(start-transition [this screen entities] (start-transition [this screen entities]
@@ -1675,7 +1679,7 @@ void main ()
(transition-done? [this screen entities] (transition-done? [this screen entities]
(animation! (get-in entities [:inventory :anim]) (animation! (get-in entities [:inventory :anim])
:is-animation-finished :is-animation-finished
(- (:total-time screen) (get-in entities [:inventory :anim-start]))))) (- ^double (:total-time screen) ^double (get-in entities [:inventory :anim-start])))))
(appear-transition state-data :show :none) (appear-transition state-data :show :none)
(reify ITransition (reify ITransition