Created
July 6, 2019 13:08
-
-
Save saikyun/cc09f0d88619e3bef287bc52c6d28431 to your computer and use it in GitHub Desktop.
Source code for get started with arcadia pt.2 on youtube
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(ns game.other-init | |
(:require [arcadia.core :refer :all] | |
[arcadia.linear :as l] | |
[arcadia.introspection :as i]) | |
(:import | |
[UnityEngine Application | |
QualitySettings])) | |
;; Don't burn my computer | |
(defn init-fps! | |
[& _] | |
(set! (.. QualitySettings vSyncCount) 0) | |
(set! (.. Application targetFrameRate) 15)) | |
(init-fps!) | |
(hook+ (object-named "Main Camera") | |
:start | |
:set-fps | |
#'init-fps!) | |
(defn clear-scene! | |
[go] | |
(doseq [c (children go)] | |
(destroy c))) | |
(defn move! | |
[go k] | |
(let [old-pos (.. go transform position) | |
velocity | |
(cond | |
(= k :move-fast) (l/v3 0.05 0 0) | |
(= k :move-slow) (l/v3 0.01 0 0) | |
:default (log (str "No speed set for" k)))] | |
(set! (.. go transform position) | |
(l/v3+ old-pos velocity)))) | |
(defn init! | |
[& _] | |
(let [holder (object-named "Beholder") | |
c1 (create-primitive :cube) | |
c2 (create-primitive :cube)] | |
(clear-scene! holder) | |
(child+ holder c1) | |
(set! (.. c1 transform position) | |
(l/v3 3 1 0)) | |
(child+ holder c2) | |
(set! (.. c2 transform position) | |
(l/v3 -3 0 0)) | |
(hook+ c1 :update :move-fast #'move!) | |
(hook+ c2 :update :move-slow #'move!))) | |
(init!) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment