fix.clj 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. (ns fix
  2. (:use
  3. arcadia.core
  4. arcadia.linear
  5. hard.core
  6. hard.input
  7. pdfn.core
  8. tween.core)
  9. (:require
  10. [arcadia.repl :as repl]))
  11. '(swap! repl/server-running not)
  12. (defn start-repl [go] (try (repl/start-server 11211) (catch Exception e (log e))))
  13. (defn update-repl [go] (try (repl/eval-queue) (catch Exception e (log e))))
  14. (defn jump-tween [o]
  15. (timeline* :loop
  16. (AND (tween {:position (v3+ (>v3 o) (v3 (?f -1 1)(?f -1 1)(?f -1 1)))} o (?f 0.1 1.0) :pow3)
  17. (tween {:local {:scale (v3 (?f 0.2 2))}} o 1.0 :pow3))
  18. (tween {:material {:color (color (?f 0.5 1)(?f 1)(?f 0.3 1))}} o 0.5 :pow3)))
  19. (defn jump [o] (dorun (map #(do % (jump-tween (clone! :sphere))) (range 100))))
  20. '(hook+ (the camera) :start #'text-message)
  21. '(hook+ (the camera) :update #'fix/update-repl)
  22. '(hook+ (the camera) :start #'fix/start-repl)
  23. '(clear-cloned!)
  24. '(require '[clojure.pprint :as pprint] )
  25. '(ppexpand (tween {:local {:position (v3 0 4 0)}} (the Sphere) 1.0))
  26. '(mapv (partial arcadia.compiler/aot-namespace "Assets/hard" ) [
  27. 'hard.animation 'hard.gobpool 'hard.input 'hard.mesh 'hard.physics 'hard.seed 'hard.sound])
  28. '(arcadia.compiler/aot-namespace "Assets/tween" 'tween.core)
  29. (deftype StringPair [^:volatile-mutable ^System.String a ^:volatile-mutable ^System.String b])
  30. (deftag System.String
  31. {:pair fix.StringPair
  32. :identity ""
  33. :lerp
  34. (fn [a b r]
  35. (let [idx (int (* (max (count a) (count b)) r))]
  36. (apply str (concat (take idx b) (drop idx a)))))})
  37. (deftween [:text-mesh :text] [this]
  38. {:base (.GetComponent this UnityEngine.TextMesh)
  39. :get (.text this)
  40. :tag System.String})
  41. (deftween [:text-mesh :color] [this]
  42. {:base (.GetComponent this UnityEngine.TextMesh)
  43. :get (.color this)
  44. :tag UnityEngine.Color})
  45. (defn text-message [o]
  46. (dorun
  47. (map
  48. #(let [o (clone! :title (v3 0 (+ 8 (* % -1.5)) 0))]
  49. (timeline* :loop
  50. (wait (* % 0.4))
  51. (tween {:text-mesh {:text "WHY HELLO THERE." :color (color 1 1 1)}} o 1.2)
  52. (wait 1.0)
  53. (tween {:text-mesh {:text " "}} o 0.7)
  54. (tween {:text-mesh {:text " :) "}} o 0.6)
  55. (wait 0.7)
  56. (tween {:text-mesh {:color (color 0 0.5 1)}} o 0.2)
  57. (tween {:text-mesh {:text "I AM NARRATION!!"}} o 0.8)
  58. (wait 0.5)
  59. (tween {:text-mesh {:color (color (?f 1)(?f 1)(?f 1))}} o 0.2)
  60. (tween {:text-mesh {:text (apply str (shuffle (seq "I AM NARRATION!!")))}} o 0.5)
  61. (wait 1)
  62. (tween {:text-mesh {:text " "}} o 0.8)))
  63. (range 20))))