Skip to content

Commit

Permalink
progress
Browse files Browse the repository at this point in the history
  • Loading branch information
ertugrulcetin committed Mar 3, 2023
1 parent 3217d8d commit 81afda1
Show file tree
Hide file tree
Showing 18 changed files with 159 additions and 49 deletions.
30 changes: 30 additions & 0 deletions enion-cljs/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions enion-cljs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
"dependencies": {
"@sentry/browser": "^7.38.0",
"@sentry/tracing": "^7.38.0",
"bad-words": "^3.0.4",
"highlight.js": "11.5.1",
"playcanvas": "^1.60.0",
"react": "17.0.2",
Expand Down
2 changes: 1 addition & 1 deletion enion-cljs/resources/public/1396021.json

Large diffs are not rendered by default.

16 changes: 8 additions & 8 deletions enion-cljs/resources/public/__settings__.js
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
ASSET_PREFIX = "";
SCRIPT_PREFIX = "";
SCENE_PATH = "1396021.json";
CONTEXT_OPTIONS = {
window.ASSET_PREFIX = "";
window.SCRIPT_PREFIX = "";
window.SCENE_PATH = "1396021.json";
window.CONTEXT_OPTIONS = {
'antialias': true,
'alpha': false,
'preserveDrawingBuffer': false,
'preferWebGl2': true,
'powerPreference': "default"
};
SCRIPTS = [ 118396797, 78753240, 111773112, 108026253, 99767394, 108026252, 109387017, 109848422, 109848430, 110329954, 112098061, 114063573, 114085216, 118401522, 118403201, 120163247, 120163248, 121963195, 123110240 ];
CONFIG_FILENAME = "config.json";
INPUT_SETTINGS = {
window.SCRIPTS = [ 118396797, 78753240, 111773112, 108026253, 99767394, 108026252, 109387017, 109848422, 109848430, 110329954, 112098061, 114063573, 114085216, 118401522, 118403201, 120163247, 120163248, 121963195, 123110240 ];
window.CONFIG_FILENAME = "config.json";
window.INPUT_SETTINGS = {
useKeyboard: true,
useMouse: true,
useGamepads: false,
useTouch: true
};
pc.script.legacy = false;
PRELOAD_MODULES = [
window.PRELOAD_MODULES = [
{'moduleName' : 'Ammo', 'glueUrl' : 'files/assets/120163247/1/ammo.wasm.js', 'wasmUrl' : 'files/assets/120163246/1/ammo.wasm.wasm', 'fallbackUrl' : 'files/assets/120163248/1/ammo.js', 'preload' : true},
];
7 changes: 3 additions & 4 deletions enion-cljs/resources/public/__start__.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// Shared Lib
var CANVAS_ID = 'application-canvas';

// Needed as we will have edge cases for particlar versions of iOS
// Needed as we will have edge cases for particular versions of iOS
// returns null if not iOS
var getIosVersion = function () {
if (/iP(hone|od|ad)/.test(navigator.platform)) {
Expand All @@ -23,10 +23,9 @@
iosVersion: getIosVersion(),

createCanvas: function () {
canvas = document.createElement('canvas'); // eslint-disable-line no-global-assign
var canvas = document.createElement('canvas');
canvas.setAttribute('id', CANVAS_ID);
canvas.setAttribute('tabindex', 0);
// canvas.style.visibility = 'hidden';

// Disable I-bar cursor on click+drag
canvas.onselectstart = function () { return false; };
Expand Down Expand Up @@ -69,7 +68,7 @@
this.resizeCanvas(app, canvas);

// Poll for size changes as the window inner height can change after the resize event for iOS
// Have one tab only, and rotrait to portrait -> landscape -> portrait
// Have one tab only, and rotate from portrait -> landscape -> portrait
if (windowSizeChangeIntervalHandler === null) {
windowSizeChangeIntervalHandler = setInterval(function () {
if (lastWindowHeight !== window.innerHeight || lastWindowWidth !== window.innerWidth) {
Expand Down
2 changes: 1 addition & 1 deletion enion-cljs/resources/public/config.json

Large diffs are not rendered by default.

10 changes: 6 additions & 4 deletions enion-cljs/src/enion_cljs/scene/entities/camera.cljs
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
(ns enion-cljs.scene.entities.camera
(:require
[applied-science.js-interop :as j]
[enion-cljs.common :refer [fire]]
[enion-cljs.scene.pc :as pc :refer [app]]
[enion-cljs.scene.states :as st]
[enion-cljs.scene.utils :as utils])
(:require-macros
[enion-cljs.scene.macros :refer [fnt]]))

(defonce state (clj->js {:eulers (pc/vec3)
:mouse-edge-range 5
:mouse-edge-range 15
:mouse-over? false
:camera-rotation-speed 10
:edge-scroll-speed 100
Expand All @@ -23,6 +22,7 @@
:last-shake-time nil}))

(comment
(j/assoc! state :mouse-edge-range 15)
(j/assoc! state :camera-rotation-speed 10)
(j/assoc! state :edge-scroll-speed 100)
(j/get state :target-angle)
Expand Down Expand Up @@ -163,12 +163,14 @@
(when (and (j/get state :mouse-over?)
(not (j/get state :right-click?))
page-x
(<= page-x (j/get state :mouse-edge-range)))
(or (<= page-x (j/get state :mouse-edge-range))
(and (st/chat-closed?) (pc/pressed? :KEY_Q))))
(j/update! eulers :x + (* dt (j/get state :edge-scroll-speed))))
(when (and (j/get state :mouse-over?)
(not (j/get state :right-click?))
page-x
(>= page-x (- js/window.innerWidth (j/get state :mouse-edge-range))))
(or (>= page-x (- js/window.innerWidth (j/get state :mouse-edge-range)))
(and (st/chat-closed?) (pc/pressed? :KEY_E))))
(j/update! eulers :x - (* dt (j/get state :edge-scroll-speed))))
(when (j/get state :wheel-clicked?)
(if (>= (j/get state :wheel-x) 180)
Expand Down
5 changes: 3 additions & 2 deletions enion-cljs/src/enion_cljs/scene/network.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
[enion-cljs.scene.skills.effects :as effects]
[enion-cljs.scene.states :as st]
[enion-cljs.scene.utils :as utils]
[enion-cljs.utils :as common.utils]
[msgpack-cljs.core :as msg]))

(defonce socket (atom nil))
Expand Down Expand Up @@ -44,7 +45,7 @@
(defn- get-potions []
(let [default {:hp-potions 0
:mp-potions 0}]
(if-let [ls (j/get js/window :localStorage)]
(if-let [ls (common.utils/get-local-storage)]
(try
(let [potions (j/call ls :getItem "potions")]
(if (str/blank? potions)
Expand All @@ -56,7 +57,7 @@

(defn- get-tutorials []
(let [default {}]
(if-let [ls (j/get js/window :localStorage)]
(if-let [ls (common.utils/get-local-storage)]
(try
(let [potions (j/call ls :getItem "tutorials")]
(if (str/blank? potions)
Expand Down
3 changes: 1 addition & 2 deletions enion-cljs/src/enion_cljs/scene/poki.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@
(when (j/get js/window :PokiSDK)
(-> (j/call-in js/window [:PokiSDK :init])
(.then #(js/console.log "Poki SDK successfully initialized"))
(.catch #(js/console.log "Initialized, but the user likely has adblock")))
(j/call-in js/window [:PokiSDK :setDebug] dev?)))
(.catch #(js/console.log "Initialized, but the user likely has adblock")))))

(defn game-loading-finished []
(when (j/get js/window :PokiSDK)
Expand Down
4 changes: 4 additions & 0 deletions enion-cljs/src/enion_cljs/scene/potions.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,7 @@
(on :rewarded-break-potions
(fn []
(update-potions 50 50)))

(comment
(update-potions 0 0)
)
35 changes: 35 additions & 0 deletions enion-cljs/src/enion_cljs/scene/skills/effects.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,35 @@
(j/call tween-opacity :start)
nil)))

(let [final-pos #js {}
y-offset (volatile! nil)]
(defn- effect-ice-spell [skill duration]
(let [new-counter (-> skill (j/update! :counter inc) (j/get :counter))
entity (j/get skill :entity)
_ (when-let [y-offset @y-offset]
(pc/set-loc-pos entity 0 y-offset 0))
first-pos (pc/get-loc-pos entity)
_ (when-not @y-offset
(vreset! y-offset (j/get first-pos :y)))
_ (j/assoc! final-pos :x (j/get first-pos :x) :y (j/get first-pos :y) :z (j/get first-pos :z))
_ (pc/setv first-pos (j/get first-pos :x) (+ (j/get first-pos :y) 1.5) (j/get first-pos :z))
_ (j/assoc! entity :enabled true)
tween-opacity (-> (j/call entity :tween first-pos)
(j/call :to final-pos duration pc/linear))
_ (j/call tween-opacity :on "complete"
(fn []
(js/setTimeout
(fn []
(when (= new-counter (j/get skill :counter))
(j/assoc! entity :enabled false)))
2000)))]
(j/call tween-opacity :start)
nil)))

(comment
(effect-ice-spell (j/get-in player [:effects :attack_ice]) 0.25)
)

(let [last-state #js {:value 0}]
(defn- effect-particle-fade-out
([skill duration]
Expand Down Expand Up @@ -139,6 +168,12 @@
(defn apply-effect-phantom-vision [state]
(effect-opacity-fade-out (j/get-in state [:effects :asas_eyes]) 2.5))

(defn apply-effect-ice-spell [state]
(effect-ice-spell (j/get-in state [:effects :attack_ice]) 0.5))

(comment
(apply-effect-ice-spell player))

(defn apply-effect-hp-potion [state]
(effect-particle-fade-out (j/get-in state [:effects :particle_hp_potion]) 1.5))

Expand Down
5 changes: 3 additions & 2 deletions enion-cljs/src/enion_cljs/scene/utils.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
(:require
[applied-science.js-interop :as j]
[enion-cljs.common :refer [fire on]]
[enion-cljs.scene.states :as st]))
[enion-cljs.scene.states :as st]
[enion-cljs.utils :as common.utils]))

(defn rand-between [min max]
(+ (Math/floor (* (Math/random) (+ (- max min) 1))) min))
Expand All @@ -12,7 +13,7 @@
(= "visible" (j/get js/document :visibilityState))))

(defn set-item [k v]
(when-let [ls (j/get js/window :localStorage)]
(when-let [ls (common.utils/get-local-storage)]
(.setItem ls k v)))

(defn finish-tutorial-step [tutorial-step]
Expand Down
14 changes: 8 additions & 6 deletions enion-cljs/src/enion_cljs/ui/events.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,16 @@
[clojure.string :as str]
[enion-cljs.common :as common :refer [fire]]
[enion-cljs.ui.db :as db]
[enion-cljs.ui.utils :as ui.utils]
[enion-cljs.utils :as common.utils]
[re-frame.core :refer [reg-event-db reg-event-fx dispatch reg-fx reg-cofx inject-cofx]]))

(defonce throttle-timeouts (atom {}))

(def default-settings
{:sound? true
:fps? true
:ping? true
:fps? false
:ping? false
:minimap? true
:camera-rotation-speed 10
:edge-scroll-speed 100
Expand All @@ -27,14 +29,14 @@
(reg-fx
::set-to-ls
(fn [[k v]]
(when-let [ls (j/get js/window :localStorage)]
(when-let [ls (common.utils/get-local-storage)]
(.setItem ls k v))))

(reg-cofx
::settings
(fn [cofx _]
(try
(if-let [ls (j/get js/window :localStorage)]
(if-let [ls (common.utils/get-local-storage)]
(assoc cofx :settings (let [settings (j/call ls :getItem "settings")]
(if (str/blank? settings)
default-settings
Expand Down Expand Up @@ -173,8 +175,8 @@
(assoc-in [:chat-box :message] ""))
:fx [(when-not (str/blank? msg)
(if (= chat-type :all)
[::fire [:send-global-message msg]]
[::fire [:send-party-message msg]]))
[::fire [:send-global-message (ui.utils/clean msg)]]
[::fire [:send-party-message (ui.utils/clean msg)]]))
[::fire [:chat-open? false]]]}
(not input-open?) {:db (assoc-in db [:chat-box :active-input?] true)
:fx [[::fire [:chat-open? true]]]})))))
Expand Down
2 changes: 1 addition & 1 deletion enion-cljs/src/enion_cljs/ui/styles.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -585,7 +585,7 @@

(defclass online-counter [ping? fps?]
{:composes [(ping-counter nil nil)]
:color "grey"
:color "white"
:top (cond
(and ping? fps?) "80px"
(and ping? (not fps?)) "40px"
Expand Down
11 changes: 11 additions & 0 deletions enion-cljs/src/enion_cljs/ui/utils.cljs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
(ns enion-cljs.ui.utils
(:require
["bad-words" :as bad-words]
[clojure.string :as str]))

(def bad-words-filter (new bad-words))

(defn- clean [text]
(when-not (str/blank? text)
(.clean bad-words-filter text)))

Loading

0 comments on commit 81afda1

Please sign in to comment.