[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

Re: [pygame] Pixel perfect collision detection sugestion



"""
You fly your little chopper in a cave and you get realy close to the walls in a
tight passage....with pixel perfect you make it through (phuew!)...with
rectangle (or even with circle based) your copper might explode even though
you (the player) clearly could see it was at least two or three pixels
between the chopper and the wall(!!).
"""

Not so.  You'll find in the majority of games, the collision box is slightly smaller than the in-game sprite for the player.  For an extreme example, try playing a Japanese shmup, where the hit-box is limited to the player's cockpit.

When I wanted to modify the rect collision system in my engine, I found it rather easy to decouple the main rect and substitute my own arbitrary rect (which was positioned at the "feet" of the sprite, same width, half as tall) and collision functions using these new rects by basically overloading the default classes and functions.  So, I'm guessing that regardless of the final approaches, they should all be abstracted that switching between them should remain this painless.

--
Andrew Ulysses Baker
"failrate"