Advertisement
Guest User

Untitled

a guest
Jul 17th, 2019
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.23 KB | None | 0 0
  1. (ns game.other-init
  2. (:require [arcadia.core :refer :all]
  3. [arcadia.linear :as l]
  4. [arcadia.introspection :as i])
  5. (:import
  6. [UnityEngine Application
  7. QualitySettings]))
  8.  
  9. ;; Don't burn my computer
  10. (defn init-fps!
  11. [& _]
  12. (set! (.. QualitySettings vSyncCount) 0)
  13. (set! (.. Application targetFrameRate) 15))
  14.  
  15. (init-fps!)
  16.  
  17. (hook+ (object-named "Main Camera")
  18. :start
  19. :set-fps
  20. #'init-fps!)
  21.  
  22. (defn clear-scene!
  23. [go]
  24. (doseq [c (children go)]
  25. (destroy c)))
  26.  
  27. (defn move!
  28. [go k]
  29. (let [old-pos (.. go transform position)
  30. velocity
  31. (cond
  32. (= k :move-fast) (l/v3 0.05 0 0)
  33. (= k :move-slow) (l/v3 0.01 0 0)
  34. :default (log (str "No speed set for" k)))]
  35. (set! (.. go transform position)
  36. (l/v3+ old-pos velocity))))
  37.  
  38. (defn init!
  39. [& _]
  40. (let [holder (object-named "Beholder")
  41. c1 (create-primitive :cube)
  42. c2 (create-primitive :cube)]
  43. (clear-scene! holder)
  44.  
  45. (child+ holder c1)
  46. (set! (.. c1 transform position)
  47. (l/v3 3 1 0))
  48.  
  49. (child+ holder c2)
  50. (set! (.. c2 transform position)
  51. (l/v3 -3 0 0))
  52.  
  53. (hook+ c1 :update :move-fast #'move!)
  54. (hook+ c2 :update :move-slow #'move!)))
  55.  
  56. (init!)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement