Skip to content

Instantly share code, notes, and snippets.

@selfsame
Last active August 29, 2015 14:26
Show Gist options
  • Select an option

  • Save selfsame/49fe7f0da296d845cf6d to your computer and use it in GitHub Desktop.

Select an option

Save selfsame/49fe7f0da296d845cf6d to your computer and use it in GitHub Desktop.
;predicate maker
(defn name-is? [s] (fn [x] (if-let [go (->go x)] (= (.name go) s) false)))
(defn mat-tint [go color]
((tween.core/material-color color 0.2 :pow2) go))
(rule collide-with [a b] {}
(mat-tint a (color 1 1 1)))
;default rule
(rule collide-with [a b]
{b (name-is? "floor")}
(mat-tint a (color 0 0.8 0.4)))
;more specific rules
(rule collide-with [a b]
{b (name-is? "wall")}
(mat-tint a (color 1 0 0)))
(rule collide-with [a b]
{b (name-is? "player")}
(mat-tint a (color 0 0 1)))
(rule bump-enter [c collision tag id] {}
(collide-with (->go c) (.collider collision)))
(rule bump-exit [c collision tag id] {}
(mat-tint (->go c) (color 1 1 1)))
(let [player (clone! :player)
floor (clone! :floor)
wall (clone! :wall)
handler (.AddComponent player Handler)]
(for [i (range 70)
:let [p (clone! :player)]]
(do (position! p (rand-vec [290 310] [170 180] [-10 10]))
(.AddComponent p Handler))
))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment