[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[pygame] Collision detection
Howdy all,
The time has come in my current game to work on collision detection. Always
before I've done basic detection....like, a simple rect colliding with
another rect that always moves by a discrete XY displacement, no rotation, no
physics, etc. Right now I'm doing a simple (haww....well, it's supposed to
be) top-down racer. The car turns and goes where it's pointed, as opposed to
simply "sliding" in the style of the old arcade racers.
I started with a collision-point approach. I currently have seperate
collision point objects which I can "attach" to the car, by specifying an
angle and distance from the center of the car. This yields an absolute XY
coord, so I do currently know where my collision points are. That's about as
far as I've gotten. :) If I just wanted the car to run into rectangular
buildings (just checking to see if a point has come within the XY range of
the building), it would probably be relatively straightforward. But that
isn't satisfactory, plus I need to be able to have cars run into each other.
I've been google'ing but so far haven't come up with much. I figure SURELY
other Pygame designers have come up with solutions to this sort of
problem. :) I was wondering if some of you folks would care to share your
techniques or some general pointers. I don't really know where to go from
here, and I'm not exactly sure what kind of approach would work best at this
point anyway.
-Matt Bailey