shmups. It provides a routine to check whether two moving circles
collided during the past frame.
+If Pyrex was available when installing, this will used optimized
+versions of the functions.
+
Basic Usage:
from bulletml.collision import collides
Usually, you'll want to use the 'collides' method instead, but
this one can be useful for just checking to see if the player has
entered an area or hit a stationary oject.
+
+ (This function is unoptimized.)
"""
dx = a.x - b.x
px, py - not required, defaults to x, y, previous frame position
radius - not required, defaults to 0.5
+ (This function is unoptimized.)
+
"""
# Current locations.
xa = a.x
# dist_sq < radius_sq
return dist_x * dist_x + dist_y * dist_y <= radius * radius
+
+def collides_all(a, others):
+ """Filter the second argument to those that collide with the first.
+
+ This is equivalent to filter(lambda o: collides(a, o), others),
+ but is much faster when the compiled extension is available (which
+ it is not currently).
+
+ """
+ return filter(lambda o: collides(a, o), others)
+
+try:
+ from bulletml._collision import collides, overlaps, collides_all
+except ImportError:
+ pass