progress on getting ios version working well.

This commit is contained in:
Bryce Covert
2017-02-19 18:31:11 -08:00
parent 00a90e2313
commit 9c7946384e
7 changed files with 103 additions and 41 deletions

View File

@@ -8,3 +8,4 @@ move entrance to antique
inventory selected item needs to be rendered on top inventory selected item needs to be rendered on top
CLOJURE 1.8 direct linking

View File

@@ -181,7 +181,8 @@
(and (get-in entities [:state :active?]) (and (get-in entities [:state :active?])
(or (not (get-in entities [:state :hud-active?])) (or (not (get-in entities [:state :hud-active?]))
(get-in entities [:fg-actions :script-running?])) (get-in entities [:fg-actions :script-running?]))
(= 0.0 (get-in entities [:fade :opacity]))) (= 0.0 (get-in entities [:fade :opacity]))
(not (get-in entities [:cam :pinching])))
(left-click screen entities options) (left-click screen entities options)
:else :else
@@ -1013,7 +1014,8 @@
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}]
(utils/update-override screen (assoc-in entities [:cursor :last-pos] [input-x input-y]) options)) (when-not (get-in entities [:cam :pinching])
(utils/update-override screen (assoc-in entities [:cursor :last-pos] [input-x input-y]) options)))
(defn grab-layers [entities] (defn grab-layers [entities]
(update-in entities [:room] (update-in entities [:room]
@@ -1070,7 +1072,7 @@
(let [{cam :camera :as screen} (utils/setup-viewport screen 320 240) (let [{cam :camera :as screen} (utils/setup-viewport screen 320 240)
screen (assoc screen :total-time 0)] screen (assoc screen :total-time 0)]
(set! (. cam zoom) utils/min-zoom) (set! (. cam zoom) utils/min-zoom)
(let [shader (ShaderProgram. ^String v-shader ^String pix-shader) (let [shader (ShaderProgram. ^String (v-shader) ^String (pix-shader))
_ (log/info "shader log:" (.getLog shader)) _ (log/info "shader log:" (.getLog shader))
state (get-state @utils/selected-save) state (get-state @utils/selected-save)
start-pos [(:x state) (:y state)] start-pos [(:x state) (:y state)]
@@ -1225,33 +1227,30 @@
(update-in [:cam] dissoc :start-zoom :pinching) ))) (update-in [:cam] dissoc :start-zoom :pinching) )))
:on-pinch :on-pinch
(fn [screen entities {:keys [initial-pointer-1 initial-pointer-2]}] (fn [screen entities {:keys [initial-pointer-1 initial-pointer-2 pointer-1 pointer-2]}]
(when (and (not (get-in entities [:cam :pinching])) (log/info "pinching...")
(get-in entities [:state :active?]))
(let [[pointer-1-x pointer-1-y] (utils/unproject screen nil [(.x initial-pointer-1) (.y initial-pointer-1)])
[pointer-2-x pointer-2-y] (utils/unproject screen nil [(.x initial-pointer-2) (.y initial-pointer-2)])]
(-> entities
(remove-cam-tweens)
(assoc-in [:cursor :last-pos] [0 0])
(assoc-in [:cam :ideal-x] (* 0.5 (+ pointer-1-x pointer-2-x)))
(assoc-in [:cam :ideal-y] (* 0.5 (+ pointer-1-y pointer-2-y)))
(assoc-in [:cam :pinching] true)))))
:on-zoom
(fn [{:keys [^OrthographicCamera camera ^FitViewport viewport ^Stage renderer] :as screen} entities {:keys [initial-distance distance]}]
(when (get-in entities [:state :active?]) (when (get-in entities [:state :active?])
(let [start-zoom (get-in entities [:cam :start-zoom]) (let [start-zoom (get-in entities [:cam :start-zoom])
zoom (get-in entities [:cam :zoom]) zoom (get-in entities [:cam :zoom])
entities (as-> entities entities initial-distance (.dst initial-pointer-1 initial-pointer-2)
(if (not start-zoom) distance (.dst pointer-1 pointer-2)
(assoc-in entities [:cam :start-zoom] zoom) [pointer-1-x pointer-1-y] (utils/unproject screen nil [(.x initial-pointer-1) (.y initial-pointer-1)])
entities) [pointer-2-x pointer-2-y] (utils/unproject screen nil [(.x initial-pointer-2) (.y initial-pointer-2)])]
(remove-cam-tweens entities) (as-> entities entities
(assoc-in entities [:cam :zoom] (max utils/max-zoom (min utils/min-zoom (* (or start-zoom zoom) (/ initial-distance distance))))) (remove-cam-tweens entities)
(assoc-in entities [:cam :x] (utils/bound-to-camera (get-in entities [:cam :ideal-x]) 320 (get-in entities [:cam :zoom])) )
(assoc-in entities [:cam :y] (utils/bound-to-camera (get-in entities [:cam :ideal-y]) 240 (get-in entities [:cam :zoom])) ))] (if (not start-zoom)
entities (assoc-in entities [:cam :start-zoom] zoom)
))) entities)
(assoc-in entities [:cursor :last-pos] [0 0])
(assoc-in entities [:cam :ideal-x] (* 0.5 (+ pointer-1-x pointer-2-x)))
(assoc-in entities [:cam :ideal-y] (* 0.5 (+ pointer-1-y pointer-2-y)))
(assoc-in entities [:cam :pinching] true)
(assoc-in entities [:cam :x] (utils/bound-to-camera (get-in entities [:cam :ideal-x]) 320 (get-in entities [:cam :zoom])) )
(assoc-in entities [:cam :y] (utils/bound-to-camera (get-in entities [:cam :ideal-y]) 240 (get-in entities [:cam :zoom])) )
(assoc-in entities [:cam :zoom] (max utils/max-zoom (min utils/min-zoom (* (or start-zoom zoom) (/ initial-distance distance)))))))))
#_#_:on-scrolled #_#_:on-scrolled
(fn [{:keys [^OrthographicCamera camera ^FitViewport viewport ^Stage renderer] :as screen} entities options] (fn [{:keys [^OrthographicCamera camera ^FitViewport viewport ^Stage renderer] :as screen} entities options]

View File

@@ -1,6 +1,8 @@
(ns advent.screens.shader) (ns advent.screens.shader
(:require [advent.utils :as utils]))
(def v-shader "attribute vec4 a_position;
(def v-shader (constantly "attribute vec4 a_position;
attribute vec4 a_color; attribute vec4 a_color;
attribute vec2 a_texCoord0; attribute vec2 a_texCoord0;
@@ -13,10 +15,56 @@ void main() {
v_color = a_color; v_color = a_color;
v_texCoords = a_texCoord0; v_texCoords = a_texCoord0;
gl_Position = u_projTrans * a_position; gl_Position = u_projTrans * a_position;
}") }"))
(def pix-shader " (def mobile-pix-shader
"
#ifdef GL_ES
#define LOWP lowp
#define HIGHP highp
precision mediump float;
#else
#define LOWP
#define HIGHP
#endif
varying vec4 v_color;
varying HIGHP vec2 v_texCoords;
uniform HIGHP float multiply_amount;
uniform HIGHP float hue_amount;
uniform sampler2D u_texture;
vec4 toGrayscale(in vec4 color)
{
float average = (color.r + color.g + color.b) / 3.0;
return vec4(average, average, average, color.a);
}
vec4 colorize(in vec4 grayscale, in vec4 color)
{
return (grayscale * color);
}
void main ()
{
vec4 scaledColor = texture2D(u_texture, v_texCoords);
vec4 grayscale = toGrayscale(scaledColor);
vec4 colorizedOutput = mix(scaledColor, colorize(grayscale, v_color.rgba), hue_amount);
vec4 multiplied = mix(colorizedOutput.rgba, v_color.rgba * scaledColor.rgba, multiply_amount);
gl_FragColor = vec4(multiplied.rgb, scaledColor.a * v_color.a);
}
"
)
(def desktop-pix-shader
"
#ifdef GL_ES #ifdef GL_ES
#define LOWP lowp #define LOWP lowp
#define HIGHP highp #define HIGHP highp
@@ -64,6 +112,7 @@ void main ()
c3 *= frac.x * (1.0 - frac.y); c3 *= frac.x * (1.0 - frac.y);
c4 *= (1.0 - frac.x) * (1.0 - frac.y); c4 *= (1.0 - frac.x) * (1.0 - frac.y);
vec4 scaledColor = (c1 + c2 + c3 + c4); vec4 scaledColor = (c1 + c2 + c3 + c4);
vec4 scaledColor = texture2D(u_texture, v_texCoords);
vec4 grayscale = toGrayscale(scaledColor); vec4 grayscale = toGrayscale(scaledColor);
vec4 colorizedOutput = mix(scaledColor, colorize(grayscale, v_color.rgba), hue_amount); vec4 colorizedOutput = mix(scaledColor, colorize(grayscale, v_color.rgba), hue_amount);
@@ -74,3 +123,11 @@ void main ()
} }
") ")
(defn pix-shader []
(if utils/mobile?
mobile-pix-shader
desktop-pix-shader
))

View File

@@ -388,13 +388,18 @@
(defn make-music [r] (defn make-music [r]
(try (try
(doto (music r) (music! :set-looping true)) (if mobile?
(doto (music (str r ".mp3")) (music! :set-looping true))
(doto (music r) (music! :set-looping true)))
(catch Exception _ (catch Exception _
(doto (music (str r ".mp3")) (music! :set-looping true))))) (doto (music (str r ".mp3")) (music! :set-looping true)))))
(defn load-sound [f] (defn load-sound [f]
(try (try
(sound f) (if mobile?
(sound (str f ".mp3"))
(sound f))
(catch Exception e (catch Exception e
(log/info e) (log/info e)
(sound (str f ".mp3"))))) (sound (str f ".mp3")))))

View File

@@ -21,7 +21,7 @@
<key>CFBundleSignature</key> <key>CFBundleSignature</key>
<string>????</string> <string>????</string>
<key>CFBundleVersion</key> <key>CFBundleVersion</key>
<string>83</string> <string>93</string>
<key>MinimumOSVersion</key> <key>MinimumOSVersion</key>
<string>8.0</string> <string>8.0</string>
<key>LSRequiresIPhoneOS</key> <key>LSRequiresIPhoneOS</key>

View File

@@ -7,18 +7,18 @@
[org.clojars.notid/tools.logging "0.3.2-SNAPSHOT"] [org.clojars.notid/tools.logging "0.3.2-SNAPSHOT"]
[log4j/log4j "1.2.16"] [log4j/log4j "1.2.16"]
[org.clojure/clojure "1.8.0"] [org.clojure/clojure "1.8.0"]
[com.mobidevelop.robovm/robovm-cocoatouch "2.2.0"] [com.mobidevelop.robovm/robovm-cocoatouch "2.3.0"]
[com.mobidevelop.robovm/robovm-objc "2.2.0"] [com.mobidevelop.robovm/robovm-objc "2.3.0"]
[com.mobidevelop.robovm/robovm-rt "2.2.0"] [com.mobidevelop.robovm/robovm-rt "2.3.0"]
[com.mobidevelop.robovm/robovm-compiler "2.2.0"] [com.mobidevelop.robovm/robovm-compiler "2.3.0"]
[com.mobidevelop.robovm/robovm-dist-compiler "2.2.0"] [com.mobidevelop.robovm/robovm-dist-compiler "2.3.0"]
[play-clj "0.4.6-BRYCE"]] [play-clj "0.4.6-BRYCE"]]
:source-paths ["src/clojure" "../desktop/src-common"] :source-paths ["src/clojure" "../desktop/src-common"]
:java-source-paths ["src/java"] :java-source-paths ["src/java"]
:plugins [[lein-fruit "0.2.4-SNAPSHOT"]] :plugins [[lein-fruit "0.2.4-SNAPSHOT"]]
:javac-options ["-target" "1.7" "-source" "1.7" "-Xlint:-options"] :javac-options ["-target" "1.7" "-source" "1.7" "-Xlint:-options"]
:ios {:robovm-opts ["-config" "robovm.xml"] :ios {:robovm-opts ["-config" "robovm.xml"]
:robovm-path "/Users/brycecovert/.robovm-sdks/robovm-2.2.1-SNAPSHOT/" :robovm-path "/Users/brycecovert/.robovm-sdks/robovm-2.2.1-SNAPSHOT"
:version 2.1} :version 2.1}
:aot :all :aot :all
:main advent.core.IOSLauncher) :main advent.core.IOSLauncher)

View File

@@ -1,6 +1,6 @@
<config> <config>
<executableName>tickstales</executableName> <executableName>tickstales</executableName>
<mainClass>${app.mainclass}</mainClass> <mainClass>advent.core.IOSLauncher</mainClass>
<os>ios</os> <os>ios</os>
<arch>arm64</arch> <arch>arm64</arch>
<target>ios</target> <target>ios</target>