perf improvements, mobile working on i4s
This commit is contained in:
@@ -5,20 +5,16 @@
|
||||
:manifest {"Implementation-Version" ~version}
|
||||
|
||||
:uberjar-name "advent-standalone.jar"
|
||||
:dependencies [[com.badlogicgames.gdx/gdx "1.9.3"]
|
||||
[com.badlogicgames.gdx/gdx-backend-lwjgl "1.9.3"]
|
||||
[com.badlogicgames.gdx/gdx-platform "1.9.3" :classifier "natives-desktop"]
|
||||
[org.skummet/clojure "1.6.0"]
|
||||
:dependencies [[com.badlogicgames.gdx/gdx "1.9.4"]
|
||||
[com.badlogicgames.gdx/gdx-backend-lwjgl "1.9.4"]
|
||||
[com.badlogicgames.gdx/gdx-platform "1.9.4" :classifier "natives-desktop"]
|
||||
[org.clojure/clojure "1.8.0"]
|
||||
[org.clojars.notid/tools.logging "0.3.2-SNAPSHOT"]
|
||||
[play-clj "0.4.6-BRYCE"]
|
||||
[log4j/log4j "1.2.16"]
|
||||
[org.clojure/data.priority-map "0.0.5"]
|
||||
[org.clojure/core.async "0.2.385"]
|
||||
[org.clojure/core.async "0.1.346.0-17112a-alpha" :exclusions [org.clojure/clojure]]
|
||||
[org.im4java/im4java "1.4.0"]]
|
||||
:plugins [[org.skummet/lein-skummet "0.2.2"]]
|
||||
|
||||
:exclusions [[org.clojure/clojure]]
|
||||
[org.clojure/core.async "0.2.385"]]
|
||||
|
||||
:source-paths ["src" "src-common"]
|
||||
:javac-options ["-target" "1.7" "-source" "1.7" "-Xlint:-options"]
|
||||
:omit-source true
|
||||
@@ -28,6 +24,9 @@
|
||||
"pack-font" ["run" "-m" "com.badlogic.gdx.tools.texturepacker.TexturePacker" "resources/font-pack/" "resources/font-pack/packed/"]
|
||||
"script" ["run" "-m" "advent.analyze/dump-speech"]}
|
||||
:profiles {
|
||||
:uberjar {
|
||||
:jvm-opts ["-Duse-repl=false" "-Dui_scale=1.0" "-Dno-steam=true" "-Dclojure.compiler.direct-linking=true" "-Dis-desktop=true"]
|
||||
}
|
||||
:dev {
|
||||
:source-paths ["src" "src-common" "src-dev"]
|
||||
:jvm-opts ["-Duse-repl=true" "-Dui_scale=1.0" "-Dno-steam=true" "-Dclojure.compiler.direct-linking=true" "-Dis-desktop=true"]
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
[play-clj.ui :refer :all]
|
||||
[play-clj.utils :refer :all]
|
||||
[play-clj.g2d :refer :all]
|
||||
[clojure.tools.logging :as log]
|
||||
[clojure.set :as set]
|
||||
[advent.pathfind]
|
||||
[advent.tween :as tween]
|
||||
@@ -322,6 +323,7 @@
|
||||
(and utils/mobile? action-cursor (not item-cursor) (not= :main action-cursor))
|
||||
(assoc-in [:action-icon]
|
||||
(assoc
|
||||
;; todo reflection here
|
||||
(texture (aget all-icons 0 (.indexOf utils/+all-cursors+ (or item-cursor action-cursor))))
|
||||
:x (* utils/ui-scale 32 4) :y (* utils/ui-scale 4)
|
||||
:width (* 18 4 utils/ui-scale) :height (* 16 4 utils/ui-scale)))
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
(ns advent.screens.rooms
|
||||
(:require [advent.zone :as zone])
|
||||
(:require [advent.zone :as zone]
|
||||
[advent.utils :as utils])
|
||||
(:import [com.badlogic.gdx.graphics Pixmap Pixmap$Filter Texture Texture$TextureFilter]
|
||||
[com.badlogic.gdx.graphics.g2d TextureRegion]
|
||||
[com.badlogic.gdx.utils.viewport FitViewport]
|
||||
@@ -10,20 +11,21 @@
|
||||
(merge entity
|
||||
{:id id
|
||||
:mouse-in? (fn [entities x y]
|
||||
(if-let [box (get-in entities [:room :entities id :box])]
|
||||
((apply zone/box box) x y)
|
||||
(let [{entity-x :x entity-y :y width :width scale-x :scale-x scale-y :scale-y origin-x :origin-x origin-y :origin-y height :height region :object} (get-in entities [:room :entities id])
|
||||
|
||||
width (or width (if (instance? TextureRegion region ) (.getRegionWidth ^TextureRegion region) 0))
|
||||
height (or height (if (instance? TextureRegion region ) (.getRegionHeight ^TextureRegion region) 0))
|
||||
entity-x (- entity-x (* (or origin-x 0)
|
||||
(or scale-x 1)))
|
||||
entity-y (- entity-y (* (or origin-y 0)
|
||||
(or scale-y 1)))]
|
||||
|
||||
((zone/box entity-x entity-y
|
||||
(+ entity-x (* width (or scale-x 1)))
|
||||
(+ entity-y (* height (or scale-y 1)))) x y))))}
|
||||
(let [e (utils/get-entity entities id)]
|
||||
(if-let [[bx1 by1 bx2 by2] (:box e)]
|
||||
(zone/within bx1 by1 bx2 by2 x y)
|
||||
(let [{entity-x :x entity-y :y width :width scale-x :scale-x scale-y :scale-y origin-x :origin-x origin-y :origin-y height :height region :object} (get-in entities [:room :entities id])
|
||||
|
||||
width (or width (if (instance? TextureRegion region ) (.getRegionWidth ^TextureRegion region) 0))
|
||||
height (or height (if (instance? TextureRegion region ) (.getRegionHeight ^TextureRegion region) 0))
|
||||
entity-x (unchecked-add (float entity-x) (unchecked-multiply (float (or origin-x 0))
|
||||
(float (or scale-x 1))))
|
||||
entity-y (unchecked-add (float entity-y) (unchecked-multiply (float (or origin-y 0))
|
||||
(float (or scale-y 1))))]
|
||||
|
||||
(zone/within entity-x entity-y
|
||||
(unchecked-add (float entity-x) (unchecked-multiply (float width) (float (or scale-x 1))))
|
||||
(unchecked-add (float entity-y) (unchecked-multiply (float height) (float (or scale-y 1)))) x y)))))}
|
||||
(when (or script scripts only-script)
|
||||
{:get-script (fn [cursor [x y]]
|
||||
(cond only-script
|
||||
@@ -43,7 +45,8 @@
|
||||
(merge spec
|
||||
(when box
|
||||
{:mouse-in? (fn [_ x y]
|
||||
((apply zone/box box) x y))})
|
||||
(let [[bx1 by1 bx2 by2] box]
|
||||
(zone/within bx1 by1 bx2 by2 x y)))})
|
||||
(when (or script scripts only-script)
|
||||
{:get-script (fn [cursor [x y]]
|
||||
(cond only-script
|
||||
@@ -61,7 +64,6 @@
|
||||
{:id id}))
|
||||
entities (into {} (for [[id entity] entities]
|
||||
[id (make-entity id entity)]))]
|
||||
(println "MAKING")
|
||||
(merge params {:collision (advent.pathfind/map-from-resource collision)
|
||||
:interactions interactions-as-list
|
||||
:entities entities})))
|
||||
|
||||
@@ -41,7 +41,7 @@
|
||||
[advent.screens.dialogue :refer [talking-screen toast-screen tooltip-screen]]
|
||||
[advent.screens.inventory :refer [inventory-screen]]
|
||||
|
||||
[clojure.core.async :refer [put! <! <!! >! chan go thread take! alts!! dropping-buffer]])
|
||||
[clojure.core.async :refer [put! poll! <! <!! >! chan go thread take! alts!! dropping-buffer]])
|
||||
(:import [com.badlogic.gdx.graphics Pixmap$Format Pixmap Pixmap$Filter Texture Texture$TextureFilter GL20 GL30]
|
||||
[com.badlogic.gdx.graphics.g2d TextureRegion Animation Batch]
|
||||
[com.badlogic.gdx.math Vector3 Matrix4]
|
||||
@@ -773,7 +773,7 @@
|
||||
(let [{{:keys [script-running? script-chan]} key} entities]
|
||||
(if script-running?
|
||||
entities
|
||||
(let [next-script (<! script-chan)]
|
||||
(let [next-script (poll! script-chan)]
|
||||
(if next-script
|
||||
(do
|
||||
(next-script entities)
|
||||
@@ -795,7 +795,7 @@
|
||||
(update-in terminated [key] assoc :current nil :started? false)
|
||||
key))
|
||||
(assoc-in entities [key :started?] true)))
|
||||
(let [current (<! channel)]
|
||||
(let [current (poll! channel)]
|
||||
|
||||
(-> entities
|
||||
(assoc-in [key :started?] false)
|
||||
@@ -861,17 +861,17 @@
|
||||
(if (and (= current-frame-index (:current-frame-index entity) (:previous-frame-index entity))
|
||||
(not (:force-rerender entity)))
|
||||
entity
|
||||
(merge (assoc entity
|
||||
:object (.getKeyFrame ^Animation anim (- total-time anim-start) anim-loop?)
|
||||
:force-rerender nil
|
||||
:current-frame-index current-frame-index
|
||||
:previous-frame-index previous-frame-index
|
||||
:origin-x (or (-> entity :anim-origins (get anim) (nth 0))
|
||||
(:base-origin-x entity)
|
||||
(:origin-x entity))
|
||||
:origin-y (or (-> entity :anim-origins (get anim) (nth 1))
|
||||
(:base-origin-y entity)
|
||||
(:origin-y entity)))
|
||||
(merge (-> entity
|
||||
(assoc :object (.getKeyFrame ^Animation anim (- total-time anim-start) anim-loop?))
|
||||
(assoc :force-rerender nil)
|
||||
(assoc :current-frame-index current-frame-index)
|
||||
(assoc :previous-frame-index previous-frame-index)
|
||||
(assoc :origin-x (or (-> entity :anim-origins (get anim) (nth 0))
|
||||
(:base-origin-x entity)
|
||||
(:origin-x entity)))
|
||||
(assoc :origin-y (or (-> entity :anim-origins (get anim) (nth 1))
|
||||
(:base-origin-y entity)
|
||||
(:origin-y entity))))
|
||||
(or (-> entity :anim-merges (get anim))
|
||||
(-> entity :anim-merges :default))))))
|
||||
|
||||
@@ -986,6 +986,8 @@
|
||||
(Matrix4/mul (.val parallax-combined) (.val parallax-view))
|
||||
|
||||
|
||||
;; todo turn this into a thing that overrides projection matrices
|
||||
;; and renders using regular render
|
||||
(let [^Batch batch (.getBatch renderer)]
|
||||
|
||||
|
||||
@@ -1068,6 +1070,120 @@
|
||||
(defn remove-cam-tweens [entities]
|
||||
(update-in entities [:tweens] dissoc :cam-x :cam-y :cam-zoom))
|
||||
|
||||
(defn render [{:keys [^OrthographicCamera camera ^FitViewport viewport ^Stage renderer] :as screen} {{:keys [last-pos ] [cursor-offset-x cursor-offset-y] :offset} :cursor :keys [tweens] :as entities} options]
|
||||
#_(steam/update)
|
||||
(.apply viewport)
|
||||
|
||||
(if (get-in entities [:closing? :value])
|
||||
|
||||
(let [entities (utils/apply-tweens screen entities tweens)
|
||||
entities (update-current-sound-vols! entities)
|
||||
entities (remove-ended-sounds screen entities)
|
||||
get-rendered (partial get-rendered entities)
|
||||
entities (loop [entities entities
|
||||
[[k e] & rest] (seq (get-in entities [:room :entities]))]
|
||||
(if k
|
||||
(recur (update-in entities [:room :entities k] get-rendered) rest)
|
||||
entities))
|
||||
entities (grab-layers entities)
|
||||
layers (get-in entities [:room :current-layers])
|
||||
all-entities (-> layers (into (vals (get-in entities [:room :entities]))) (conj (:white-fade entities)))]
|
||||
(screen! fade-screen :update-fade {:opacity (get-in entities [:fade :opacity])})
|
||||
(doseq [m (vals (get-in entities [:musics]))]
|
||||
(when m
|
||||
(music! m :set-volume (utils/current-music-volume (get-in entities [:volume :value])))))
|
||||
|
||||
(clear!)
|
||||
(doseq [e (sort-by :baseline all-entities)]
|
||||
(if (:parallax e)
|
||||
(render-parallax screen e)
|
||||
(render! screen [e])))
|
||||
entities)
|
||||
(let [entities (fade-in-first-time-if-necessary screen entities)
|
||||
entities (utils/apply-tweens screen entities tweens)
|
||||
entities (update-cursor screen entities)
|
||||
entities (start-script-if-necessary screen entities :fg-actions)
|
||||
entities (update-from-script screen entities :fg-actions)
|
||||
entities (start-script-if-necessary screen entities :bg-actions)
|
||||
entities (update-from-script screen entities :bg-actions)
|
||||
entities (update-from-room screen entities)
|
||||
entities (update-from-hotspots screen entities)
|
||||
[last-pos-x last-pos-y] (utils/unproject screen nil last-pos)
|
||||
last-pos-x (double last-pos-x)
|
||||
last-pos-y (double last-pos-y)
|
||||
entities (if (and (@utils/settings :camera-man? true)
|
||||
(not (get-in entities [:cam :paused?]))
|
||||
(nil? (get-in entities [:tweens :cam-x]))
|
||||
(= 1 (rand-int 20)))
|
||||
(if (= (rand-int 2) 1)
|
||||
(actions/pan-to screen entities
|
||||
(get-in entities [:room :entities :ego :x])
|
||||
(get-in entities [:room :entities :ego :y])
|
||||
(constantly (get-in entities [:room :entities :ego :scale-x]))
|
||||
tween/ease-in-out-quadratic
|
||||
5.0)
|
||||
(actions/pan-to screen entities
|
||||
(+ ^double (get-in entities [:cam :x] 0)
|
||||
(- 10 ^double (rand-int 20)))
|
||||
(+ ^double (get-in entities [:cam :y] 0)
|
||||
(- 10 ^double (rand-int 20)))
|
||||
(constantly (get-in entities [:room :entities :ego :scale-x]))
|
||||
tween/ease-in-out-quadratic
|
||||
5.0))
|
||||
entities)
|
||||
|
||||
|
||||
entities (grab-layers entities)
|
||||
update-room (fn [{:keys [anim update-fn] :as e}]
|
||||
(let [e (if (:anim e)
|
||||
(animate e screen)
|
||||
e)
|
||||
|
||||
e (if update-fn
|
||||
(update-fn screen (get-in entities [:room :entities]) e)
|
||||
e)
|
||||
e (get-rendered entities e)]
|
||||
e))
|
||||
entities (loop [room (transient (get-in entities [:room :entities]))
|
||||
[[k e] & rest] (doall (seq (get-in entities [:room :entities])))]
|
||||
(if k
|
||||
(recur (assoc! room k (update-room e))
|
||||
rest)
|
||||
(assoc-in entities [:room :entities] (persistent! room))))
|
||||
layers (get-in entities [:room :current-layers])
|
||||
all-entities (-> layers (into (vals (get-in entities [:room :entities]))) (conj (:white-fade entities)))]
|
||||
|
||||
(screen! tooltip-screen :on-hover-start {:hover-text (get-in entities [:label :text])
|
||||
:scene-viewport (:viewport screen)
|
||||
:cursor (:cursor entities)
|
||||
:x (unchecked-subtract last-pos-x
|
||||
cursor-offset-x)
|
||||
:y (unchecked-add (unchecked-subtract last-pos-y 16 )
|
||||
cursor-offset-y)})
|
||||
|
||||
(clear!)
|
||||
(screen! talking-screen :on-update-camera { :scene-viewport (:viewport screen) :scene-camera (:camera screen)})
|
||||
(screen! fade-screen :update-fade { :opacity (get-in entities [:fade :opacity])})
|
||||
(when true #_(not (get-in entities [:cam :paused?]))
|
||||
(set! (. camera zoom) (:zoom (:cam entities)))
|
||||
(set! (.. camera position x) (:x (:cam entities) 160.0))
|
||||
(set! (.. camera position y) (:y (:cam entities) 120.0)))
|
||||
(let [entities (if utils/mobile?
|
||||
(utils/update-override screen entities options)
|
||||
(utils/update-override screen entities options))
|
||||
entities (play-key-sounds screen entities)
|
||||
entities (update-current-sound-vols! entities)
|
||||
entities (remove-ended-sounds screen entities)]
|
||||
(doseq [m (vals (get-in entities [:musics]))]
|
||||
(when m
|
||||
(music! m :set-volume (utils/current-music-volume (get-in entities [:volume :value])))))
|
||||
(doseq [e (doall (sort-by :baseline all-entities))]
|
||||
(if (:parallax e)
|
||||
(render-parallax screen e)
|
||||
(render! screen [e])))
|
||||
|
||||
entities))))
|
||||
|
||||
|
||||
(defscreen scene
|
||||
:on-timer
|
||||
@@ -1123,14 +1239,14 @@
|
||||
:inside-antique (utils/make-music "music/inside-antique.ogg")
|
||||
:town-1 (utils/make-music "music/town-music-1.ogg")
|
||||
:town-2 (utils/make-music "music/town-music-2.ogg")
|
||||
#_#_:love (utils/make-music "music/love.ogg")
|
||||
#_#_:inside-fangald (utils/make-music "music/inside-fangald.ogg")
|
||||
#_#_:fight (utils/make-music "music/megaboss.mp3")
|
||||
#_#_:pull-sword (utils/make-music "music/pull-sword.ogg")
|
||||
#_#_:night (utils/make-music "music/night.ogg")
|
||||
#_#_:dream (utils/make-music "dream/music.ogg")
|
||||
#_#_:secret-hideout (utils/make-music "music/secret-hideout.ogg")
|
||||
#_#_:wind (utils/make-music "music/wind.ogg")}
|
||||
:love (utils/make-music "music/love.ogg")
|
||||
:inside-fangald (utils/make-music "music/inside-fangald.ogg")
|
||||
:fight (utils/make-music "music/megaboss.mp3")
|
||||
:pull-sword (utils/make-music "music/pull-sword.ogg")
|
||||
:night (utils/make-music "music/night.ogg")
|
||||
:dream (utils/make-music "dream/music.ogg")
|
||||
:secret-hideout (utils/make-music "music/secret-hideout.ogg")
|
||||
:wind (utils/make-music "music/wind.ogg")}
|
||||
:state state
|
||||
:time-profiles {:object nil
|
||||
:default utils/default-night-merge
|
||||
@@ -1268,120 +1384,8 @@
|
||||
|
||||
(update-in entities [:cam :zoom] #(* % (+ 1 (/ (double (:amount options)) 10.0 )))))
|
||||
|
||||
:on-render
|
||||
(fn [{:keys [^OrthographicCamera camera ^FitViewport viewport ^Stage renderer] :as screen} {{:keys [last-pos ] [cursor-offset-x cursor-offset-y] :offset} :cursor :keys [tweens] :as entities} options]
|
||||
#_(steam/update)
|
||||
(.apply viewport)
|
||||
|
||||
(if (get-in entities [:closing? :value])
|
||||
|
||||
(let [entities (utils/apply-tweens screen entities tweens)
|
||||
entities (update-current-sound-vols! entities)
|
||||
entities (remove-ended-sounds screen entities)
|
||||
get-rendered (partial get-rendered entities)
|
||||
entities (loop [entities entities
|
||||
[[k e] & rest] (seq (get-in entities [:room :entities]))]
|
||||
(if k
|
||||
(recur (update-in entities [:room :entities k] get-rendered) rest)
|
||||
entities))
|
||||
entities (grab-layers entities)
|
||||
layers (get-in entities [:room :current-layers])
|
||||
all-entities (concat layers (vals (get-in entities [:room :entities])) [(:white-fade entities)])]
|
||||
(screen! fade-screen :update-fade {:opacity (get-in entities [:fade :opacity])})
|
||||
(doseq [m (vals (get-in entities [:musics]))]
|
||||
(when m
|
||||
(music! m :set-volume (utils/current-music-volume (get-in entities [:volume :value])))))
|
||||
|
||||
(clear!)
|
||||
(doseq [e (sort-by :baseline all-entities)]
|
||||
(if (:parallax e)
|
||||
(render-parallax screen e)
|
||||
(render! screen [e])))
|
||||
entities)
|
||||
(let [entities (fade-in-first-time-if-necessary screen entities)
|
||||
entities (utils/apply-tweens screen entities tweens)
|
||||
entities (update-cursor screen entities)
|
||||
entities (start-script-if-necessary screen entities :fg-actions)
|
||||
entities (update-from-script screen entities :fg-actions)
|
||||
entities (start-script-if-necessary screen entities :bg-actions)
|
||||
entities (update-from-script screen entities :bg-actions)
|
||||
entities (update-from-room screen entities)
|
||||
entities (update-from-hotspots screen entities)
|
||||
[last-pos-x last-pos-y] (utils/unproject screen nil last-pos)
|
||||
last-pos-x (double last-pos-x)
|
||||
last-pos-y (double last-pos-y)
|
||||
entities (if (and (@utils/settings :camera-man? true)
|
||||
(not (get-in entities [:cam :paused?]))
|
||||
(nil? (get-in entities [:tweens :cam-x]))
|
||||
(= 1 (rand-int 20)))
|
||||
(if (= (rand-int 2) 1)
|
||||
(actions/pan-to screen entities
|
||||
(get-in entities [:room :entities :ego :x])
|
||||
(get-in entities [:room :entities :ego :y])
|
||||
(constantly (get-in entities [:room :entities :ego :scale-x]))
|
||||
tween/ease-in-out-quadratic
|
||||
5.0)
|
||||
(actions/pan-to screen entities
|
||||
(+ ^double (get-in entities [:cam :x] 0)
|
||||
(- 10 ^double (rand-int 20)))
|
||||
(+ ^double (get-in entities [:cam :y] 0)
|
||||
(- 10 ^double (rand-int 20)))
|
||||
(constantly (get-in entities [:room :entities :ego :scale-x]))
|
||||
tween/ease-in-out-quadratic
|
||||
5.0))
|
||||
entities)
|
||||
|
||||
|
||||
entities (grab-layers entities)
|
||||
update-room (fn [{:keys [anim update-fn] :as e}]
|
||||
(let [e (if (:anim e)
|
||||
(animate e screen)
|
||||
e)
|
||||
|
||||
e (if update-fn
|
||||
(update-fn screen (get-in entities [:room :entities]) e)
|
||||
e)
|
||||
e (get-rendered entities e)]
|
||||
e))
|
||||
entities (loop [room (transient (get-in entities [:room :entities]))
|
||||
[[k e] & rest] (doall (seq (get-in entities [:room :entities])))]
|
||||
(if k
|
||||
(recur (assoc! room k (update-room e))
|
||||
rest)
|
||||
(assoc-in entities [:room :entities] (persistent! room))))
|
||||
layers (get-in entities [:room :current-layers])
|
||||
all-entities (concat layers (vals (get-in entities [:room :entities])) [(:white-fade entities)])]
|
||||
|
||||
(screen! tooltip-screen :on-hover-start {:hover-text (get-in entities [:label :text])
|
||||
:scene-viewport (:viewport screen)
|
||||
:cursor (:cursor entities)
|
||||
:x (unchecked-subtract last-pos-x
|
||||
cursor-offset-x)
|
||||
:y (unchecked-add (unchecked-subtract last-pos-y 16 )
|
||||
cursor-offset-y)})
|
||||
|
||||
(clear!)
|
||||
(screen! talking-screen :on-update-camera { :scene-viewport (:viewport screen) :scene-camera (:camera screen)})
|
||||
(screen! fade-screen :update-fade { :opacity (get-in entities [:fade :opacity])})
|
||||
(when true #_(not (get-in entities [:cam :paused?]))
|
||||
(set! (. camera zoom) (:zoom (:cam entities)))
|
||||
(set! (.. camera position x) (:x (:cam entities) 160.0))
|
||||
(set! (.. camera position y) (:y (:cam entities) 120.0)))
|
||||
(let [entities (if utils/mobile?
|
||||
(utils/update-override screen entities options)
|
||||
(utils/update-override screen entities options))
|
||||
entities (play-key-sounds screen entities)
|
||||
entities (update-current-sound-vols! entities)
|
||||
entities (remove-ended-sounds screen entities)]
|
||||
(doseq [m (vals (get-in entities [:musics]))]
|
||||
(when m
|
||||
(music! m :set-volume (utils/current-music-volume (get-in entities [:volume :value])))))
|
||||
(doseq [e (doall (sort-by :baseline all-entities))]
|
||||
(if (:parallax e)
|
||||
(render-parallax screen e)
|
||||
(render! screen [e])))
|
||||
|
||||
entities))))
|
||||
:on-render render
|
||||
|
||||
|
||||
:on-resize (fn [{:keys [^FitViewport viewport]} entities {:keys [width height]}]
|
||||
(.update viewport width height true))
|
||||
|
||||
@@ -128,15 +128,19 @@
|
||||
|
||||
(defonce selected-save (atom nil))
|
||||
|
||||
(defn current-music-volume [& [^double factor]]
|
||||
(-> (Math/pow (unchecked-multiply (:music-volume @settings) 0.01) 2)
|
||||
(unchecked-multiply 0.25)
|
||||
(unchecked-multiply (or factor 1.0))))
|
||||
(defn current-music-volume
|
||||
([] (current-music-volume 1.0))
|
||||
([^double factor]
|
||||
(-> (Math/pow (unchecked-multiply (:music-volume @settings) 0.01) 2)
|
||||
(unchecked-multiply 0.25)
|
||||
(unchecked-multiply (double factor)))))
|
||||
|
||||
(defn current-sound-volume [& [factor]]
|
||||
(-> (Math/pow (unchecked-multiply (:sound-volume @settings) 0.01) 2)
|
||||
(unchecked-multiply 0.5)
|
||||
(unchecked-multiply (or factor 1.0))))
|
||||
(defn current-sound-volume
|
||||
([] (current-sound-volume 1.0))
|
||||
([^double factor]
|
||||
(-> (Math/pow (unchecked-multiply (:sound-volume @settings) 0.01) 2)
|
||||
(unchecked-multiply 0.5)
|
||||
(unchecked-multiply (double factor)))))
|
||||
|
||||
(defn cursor [filename which]
|
||||
(let [scale 4
|
||||
@@ -700,7 +704,7 @@
|
||||
entities)))
|
||||
|
||||
(defn stop-all-sounds! [entities]
|
||||
(doseq [snd (get-in entities [:current-sounds :value])]
|
||||
(doseq [snd (get-in entities [:current-sounds :value] [])]
|
||||
(sound! (:sound snd) :stop (:id snd))))
|
||||
|
||||
(defn translate-depressed [cursor depressed?]
|
||||
@@ -714,3 +718,6 @@
|
||||
(min (- length (* length 0.5 zoom ))
|
||||
(max (* length 0.5 zoom )
|
||||
x)))
|
||||
|
||||
(defn get-entity [entities id]
|
||||
((:entities (:room entities)) id))
|
||||
|
||||
@@ -1,7 +1,14 @@
|
||||
(ns advent.zone)
|
||||
|
||||
(defn within [x1 y1 x2 y2 x3 y3]
|
||||
(and
|
||||
(< x1 x3)
|
||||
(< x3 x2)
|
||||
(< y1 y3)
|
||||
(< y3 y2)))
|
||||
|
||||
(defn box [x1 y1 x2 y2]
|
||||
(fn [x y]
|
||||
(and
|
||||
(< x1 x x2)
|
||||
(< y1 y y2))))
|
||||
(within x1 y1 x2 y2 x y)))
|
||||
|
||||
|
||||
|
||||
@@ -35,6 +35,8 @@
|
||||
(System/setProperty "org.lwjgl.opengl.Display.disableOSXFullscreenModeAPI" "true")
|
||||
#_(System/setProperty "org.lwjgl.opengl.Window.undecorated", "true")
|
||||
|
||||
|
||||
(log/info "Starting game")
|
||||
(let [app (LwjglApplication. advent cfg)]
|
||||
(when (utils/has-saved-settings?)
|
||||
(utils/load-settings!))
|
||||
|
||||
@@ -2,24 +2,22 @@
|
||||
:description "FIXME: write description"
|
||||
:dependencies [[com.badlogicgames.gdx/gdx "1.9.4"]
|
||||
[com.badlogicgames.gdx/gdx-backend-robovm "1.9.4"]
|
||||
#_[org.clojure/core.async "0.2.385"]
|
||||
[org.clojure/core.async "0.1.346.0-17112a-alpha" :exclusions [org.clojure/clojure]]
|
||||
[org.clojure/core.async "0.2.385"]
|
||||
[org.clojars.notid/tools.logging "0.3.2-SNAPSHOT"]
|
||||
[log4j/log4j "1.2.16"]
|
||||
[org.skummet/clojure "1.7.0-r2"]
|
||||
[org.clojure/clojure "1.8.0"]
|
||||
[com.mobidevelop.robovm/robovm-cocoatouch "2.3.0"]
|
||||
[com.mobidevelop.robovm/robovm-rt "2.3.0"]
|
||||
[play-clj "0.4.6-BRYCE" :exclusions [com.badlogicgames.gdx/gdx-box2d com.badlogicgames.gdx/gdx-bullet]]]
|
||||
:exclusions [[org.clojure/clojure]]
|
||||
:source-paths ["src/clojure" "../desktop/src-common"]
|
||||
:java-source-paths ["src/java"]
|
||||
:plugins [[lein-fruit "0.2.4-SNAPSHOT"]
|
||||
[org.skummet/lein-skummet "0.2.2"]
|
||||
]
|
||||
:javac-options ["-target" "1.7" "-source" "1.7" "-Xlint:-options"]
|
||||
:jvm-opts ["-Dno-steam=true" "-Dclojure.compiler.direct-linking=true" ]
|
||||
:jvm-opts ["-Dno-steam=true" "-Dclojure.compiler.direct-linking=true" "-Dclojure.compiler.elide-meta=[:doc :file :line :added]"]
|
||||
:ios {:robovm-opts ["-config" "robovm.xml"]
|
||||
:robovm-path "/Users/brycecovert/.robovm-sdks/robovm-2.2.1-SNAPSHOT"
|
||||
:version 2.1}
|
||||
:aot :all
|
||||
:main advent.core.IOSLauncher)
|
||||
:main advent.core.ios)
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
<arch>arm64</arch>
|
||||
<target>ios</target>
|
||||
<iosInfoPList>Info.plist.xml</iosInfoPList>
|
||||
<treeShaker>aggressive</treeShaker>
|
||||
<resources>
|
||||
<resource>
|
||||
<directory>resources</directory>
|
||||
@@ -25,23 +26,68 @@
|
||||
</resource>
|
||||
</resources>
|
||||
<forceLinkClasses>
|
||||
<pattern>clojure.tools.logging.**</pattern>
|
||||
<pattern>advent.**</pattern>
|
||||
<pattern>clojure.genclass*</pattern>
|
||||
<pattern>clojure.gvec*</pattern>
|
||||
<pattern>clojure.core*</pattern>
|
||||
<pattern>clojure.**</pattern> <!-- change this to optimize -->
|
||||
<pattern>clojure.core.**</pattern>
|
||||
<pattern>clojure.tools.**</pattern>
|
||||
<pattern>clojure.core.memoize*</pattern>
|
||||
<pattern>clojure.core.memoize.**</pattern>
|
||||
<pattern>clojure.core.cache*</pattern>
|
||||
<pattern>clojure.core.cache.**</pattern>
|
||||
<pattern>clojure.edn*</pattern>
|
||||
<pattern>clojure.core.server*</pattern>
|
||||
<pattern>clojure.instant*</pattern>
|
||||
<pattern>clojure.main*</pattern>
|
||||
<pattern>clojure.reflect*</pattern>
|
||||
<pattern>clojure.reflect.**</pattern>
|
||||
<pattern>clojure.set*</pattern>
|
||||
<pattern>clojure.stacktrace*</pattern>
|
||||
<pattern>clojure.walk*</pattern>
|
||||
<pattern>clojure.xml*</pattern>
|
||||
<pattern>clojure.zip*</pattern>
|
||||
<pattern>clojure.data*</pattern>
|
||||
<pattern>clojure.uuid*</pattern>
|
||||
<pattern>clojure.string*</pattern>
|
||||
<pattern>clojure.core.protocols*</pattern>
|
||||
<pattern>clojure.tools.reader*</pattern>
|
||||
<pattern>clojure.tools.reader.**</pattern>
|
||||
<pattern>clojure.tools.logging.**</pattern>
|
||||
<pattern>clojure.tools.logging*</pattern>
|
||||
<pattern>clojure.tools.analyzer*</pattern>
|
||||
<pattern>clojure.tools.analyzer.**</pattern>
|
||||
<pattern>clojure.pprint*</pattern>
|
||||
<pattern>clojure.pprint.**</pattern>
|
||||
<pattern>clojure.data.**</pattern>
|
||||
<pattern>clojure.test*</pattern>
|
||||
<pattern>clojure.test.**</pattern>
|
||||
<pattern>clojure.template*</pattern>
|
||||
<pattern>clojure.template.**</pattern>
|
||||
<pattern>clojure.java.io*</pattern>
|
||||
<pattern>play_clj.**</pattern>
|
||||
<pattern>clojure.*</pattern>
|
||||
<pattern>com.badlogic.**</pattern>
|
||||
<pattern>java.util.logging.**</pattern>
|
||||
<pattern>clojure.core.async*</pattern>
|
||||
<pattern>clojure.core.async.Mutex*</pattern>
|
||||
<pattern>clojure.core.async.ThreadLocalRandom*</pattern>
|
||||
<pattern>clojure.core.async.impl.protocols*</pattern>
|
||||
<pattern>clojure.core.async.impl.concurrent*</pattern>
|
||||
<pattern>clojure.core.async.impl.channels*</pattern>
|
||||
<pattern>clojure.core.async.impl.dispatch*</pattern>
|
||||
<pattern>clojure.core.async.impl.exec.**</pattern>
|
||||
<pattern>clojure.core.async.impl.exec*</pattern>
|
||||
<pattern>clojure.core.async.impl.buffers*</pattern>
|
||||
<pattern>clojure.core.async.impl.mutex*</pattern>
|
||||
<pattern>clojure.core.async.impl.timers*</pattern>
|
||||
<pattern>clojure.core.async.impl.ioc_macros*</pattern>
|
||||
</forceLinkClasses>
|
||||
<libs>
|
||||
<lib>libs/libObjectAL.a</lib>
|
||||
<lib>libs/libgdx.a</lib>
|
||||
</libs>
|
||||
<stripArchives>
|
||||
<exclude>**/*.class</exclude>
|
||||
<exclude>**/*.jar</exclude>
|
||||
</stripArchives>
|
||||
<frameworks>
|
||||
<framework>UIKit</framework>
|
||||
<framework>OpenGLES</framework>
|
||||
|
||||
@@ -19,6 +19,8 @@ public class IOSLauncher extends IOSApplication.Delegate {
|
||||
config.orientationPortrait = false;
|
||||
config.orientationLandscape = true;
|
||||
config.preferredFramesPerSecond = 30;
|
||||
config.useAccelerometer=false;
|
||||
config.useCompass=false;
|
||||
|
||||
RT.var("clojure.core", "require").invoke(Symbol.intern("advent.core"));
|
||||
try {
|
||||
@@ -38,4 +40,11 @@ public class IOSLauncher extends IOSApplication.Delegate {
|
||||
UIApplication.main(argv, null, IOSLauncher.class);
|
||||
pool.close();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void didReceiveMemoryWarning(UIApplication application) {
|
||||
for (int i = 0; i < 3; i++) {
|
||||
System.gc();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user