testo.cljc 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. (ns testo
  2. (:use
  3. arcadia.core
  4. arcadia.linear
  5. hard.core
  6. tween.core)
  7. (:import SimpleTiledModel))
  8. (defn text! [o s] (set! (.text (.* o >TextMesh)) s))
  9. (defn grid [a x y]
  10. (get (get a y) x))
  11. (def stm (SimpleTiledModel. "Castle" "" 10 10 false false))
  12. (def stm false)
  13. (.Run stm (rand-int 1000) 100)
  14. (def bm (.Graphics stm))
  15. (.Save bm "Assets/out.png")
  16. (log (grid (.wave stm) 1 1))
  17. (def MAP (atom {}))
  18. (log
  19. (vec
  20. (for [y (range (count (.wave stm)))
  21. :let [row (get (.wave stm) y)]]
  22. (vec
  23. (for [x (range (count (first row)))
  24. :let [tile (get row x)]]
  25. (if (= 1 (get (frequencies tile) true))
  26. (swap! MAP conj
  27. {[y x] (first
  28. (remove nil? (map-indexed
  29. #(if %2 %1)
  30. tile)))})))))))
  31. (do
  32. (clear-cloned!)
  33. (map
  34. (fn [[[x y] v]]
  35. (-> (clone! :text (v3- (v3 (- 9 x) 0 y) (v3 4.5 0 4.5)))
  36. (text! (str v))))
  37. @MAP))
  38. (timeline*
  39. #(not (.Run stm (rand-int 1000) 1))
  40. #(.Save (.Graphics stm) "Assets/out.png"))
  41. ::NOTES '[
  42. for Graphics, looking for (grid (.wave stm) 1 1) where single true, corresponds to a tile
  43. coord translation wave[z][9 - x]
  44. ]
  45. (deftype foo [^:volatile-mutable bar])
  46. (aset (foo. 7) "bar" 6)
  47. (.set_Item (foo. 7) "bar" 6)