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

Re: [pygame] Collision handling algorithm



My solution is a bit simplistic, I guess. I have lists of various types
of objects......shootable objects, solid objects, will soon have
"dangerous" objects that hurt the player, etc. Any "dynamic" entity
(mainly, the player and the player's bullets) parses through whatever
lists it needs to, doing collision checks (for bullets, it's a simple
rect overlap........for player's collision, it's more sophisticated).
Objects can of course exist in any or all of the lists (for instance, a
destroyable wall would be both solid and shootable). The lists that
actually get parsed by dynamic objects are limited to on-screen objects
only (so huge levels don't slow down the game in the future when I
actually develop some content, heh). I also have a list for "scrollable"
objects (which is just about everything), as my game supports scrolling
(player never gets outside a rectangular region on the screen), and
up/down panning.

So far it works a treat, though it seems like the methods Andrew and
Dave are using would be more flexible when collision and object types
are more varied and complex.

	-Matt Bailey