Liking cljdoc? Tell your friends :D

quip.collision


collide-groupclj

(collide-group a group-b collider)

Check a sprite from one group for collisions with all sprites from another group, updating both as necessary.

Reducing over group-b lets us build up a new version of group-b, updating the value of a as we go.

We filter out any b that returns nil after colliding to allow collide functions to kill sprites.

Check a sprite from one group for collisions with all sprites from
another group, updating both as necessary.

Reducing over group-b lets us build up a new version of group-b,
updating the value of a as we go.

We filter out any b that returns `nil` after colliding to allow
collide functions to kill sprites.
sourceraw docstring

collide-groupsclj

(collide-groups sprite-groups {:keys [group-a-key group-b-key] :as collider})

Check a group of sprites for collisions with another group of sprites, updating all sprites as necessary.

We're iterating using a reducing function over the first group, this means that each time we check an a against group-b we get the new value for a, and the new values for each sprite in group-b.

We filter out any a that returns nil after colliding to allow collide functions to kill sprites.

We build our results map using the threading macro to handle the case where group-a-key and group-b-key are the same.

Check a group of sprites for collisions with another group of
sprites, updating all sprites as necessary.

We're iterating using a reducing function over the first group, this
means that each time we check an `a` against `group-b` we get the
new value for a, and the new values for each sprite in `group-b`.

We filter out any a that returns `nil` after colliding to allow
collide functions to kill sprites.

We build our results map using the threading macro to handle the
case where `group-a-key` and `group-b-key` are the same.
sourceraw docstring

collide-spritesclj

(collide-sprites a
                 b
                 {:keys [group-a-key group-b-key collision-detection-fn
                         collide-fn-a collide-fn-b]})

Check two sprites for collision and update them with the appropriate collide-fn-<a|b> provided by the collider.

In the case that we're checking a group of sprites for collisions in the same group we need to check the uuid on the sprites to ensure they're not colliding with themselves.

Check two sprites for collision and update them with the appropriate
`collide-fn-<a|b>` provided by the collider.

In the case that we're checking a group of sprites for collisions in
the same group we need to check the uuid on the sprites to ensure
they're not colliding with themselves.
sourceraw docstring

colliderclj

(collider group-a-key
          group-b-key
          collide-fn-a
          collide-fn-b
          &
          {:keys [collision-detection-fn]
           :or {collision-detection-fn w-h-rects-collide?}})

Define a check for collision between to groups of sprites with functions to be invoked on the sprites when collision is detected.

Define a check for collision between to groups of sprites with
functions to be invoked on the sprites when collision is detected.
sourceraw docstring

equal-pos?clj

(equal-pos? {pos-a :pos} {pos-b :pos})

Predicate to check if two sprites have the same position.

Predicate to check if two sprites have the same position.
sourceraw docstring

poly-contains-pos?clj

(poly-contains-pos? a b)

Predicate to check if the position of sprite b is inside the bounding polygon of sprite a centered on its position.

Predicate to check if the position of sprite `b` is inside the
bounding polygon of sprite `a` centered on its position.
sourceraw docstring

polys-collide?clj

(polys-collide? {bounds-fn-a :bounds-fn pos-a :pos wa :w ha :h :as a}
                {bounds-fn-b :bounds-fn pos-b :pos wb :w hb :h :as b})

Predicate to check an intersection of the bounding polygons of sprites a and b centered on their positions.

Predicate to check an intersection of the bounding polygons of
sprites `a` and `b` centered on their positions.
sourceraw docstring

pos-in-poly?clj

(pos-in-poly? {pos-a :pos :as a}
              {bounds-fn :bounds-fn pos-b :pos w :w h :h :as b})

Predicate to check if the position of sprite a is inside the bounding polygon of sprite b centered on its position.

Predicate to check if the position of sprite `a` is inside the
bounding polygon of sprite `b` centered on its position.
sourceraw docstring

pos-in-rect?clj

(pos-in-rect? {pos-a :pos :as a} {[bx by] :pos bw :w bh :h :as b})

Predicate to check if the position of sprite a is inside the w by h rect of sprite b centered on its position.

Predicate to check if the position of sprite `a` is inside the `w` by
`h` rect of sprite `b` centered on its position.
sourceraw docstring

pos-in-rotating-poly?clj

(pos-in-rotating-poly?
  {pos-a :pos :as a}
  {bounds-fn :bounds-fn pos-b :pos rotation :rotation w :w h :h :as b})

Predicate to check if the position of sprite a is inside the bounding polygon of sprite b centered on its position, taking into account its rotation.

Predicate to check if the position of sprite `a` is inside the
bounding polygon of sprite `b` centered on its position, taking into
account its rotation.
sourceraw docstring

rect-contains-pos?clj

(rect-contains-pos? a b)

Predicate to check if the position of sprite b is inside the w by h rect of sprite a centered on its position.

Predicate to check if the position of sprite `b` is inside the `w` by
`h` rect of sprite `a` centered on its position.
sourceraw docstring

rotating-poly-contains-pos?clj

(rotating-poly-contains-pos? a b)

Predicate to check if the position of sprite b is inside the bounding polygon of sprite a centered on its position, taking into account its rotation.

Predicate to check if the position of sprite `b` is inside the
bounding polygon of sprite `a` centered on its position, taking into
account its rotation.
sourceraw docstring

rotating-polys-collide?clj

(rotating-polys-collide?
  {bounds-fn-a :bounds-fn pos-a :pos rotation-a :rotation wa :w ha :h :as a}
  {bounds-fn-b :bounds-fn pos-b :pos rotation-b :rotation wb :w hb :h :as b})

Predicate to check for an intersection of the bounding polys of sprites a and b centered on their positions, taking into account the rotation of both sprites.

Predicate to check for an intersection of the bounding polys of
sprites `a` and `b` centered on their positions, taking into account
the rotation of both sprites.
sourceraw docstring

update-collisionsclj

(update-collisions {:keys [current-scene] :as state})

Update the sprites in the current scene based on the scene colliders.

Update the sprites in the current scene based on the scene colliders.
sourceraw docstring

w-h-rects-collide?clj

(w-h-rects-collide? {[ax ay] :pos aw :w ah :h} {[bx by] :pos bw :w bh :h})

Predicate to check for overlap of the w by h rects of two sprites centered on their positions.

Predicate to check for overlap of the `w` by `h` rects of two sprites
centered on their positions.
sourceraw docstring

cljdoc is a website building & hosting documentation for Clojure/Script libraries

× close