Fast, accurate 2d collision
Posted
by
Neophyte
on Game Development
See other posts from Game Development
or by Neophyte
Published on 2012-10-14T18:07:03Z
Indexed on
2012/10/14
21:52 UTC
Read the original article
Hit count: 209
I'm working on a 2d topdown shooter, and now need to go beyond my basic rectangle bounding box collision system.
I have large levels with many different sprites, all of which are different shapes and sizes. The textures for the sprites are all square png files with transparent backgrounds, so I also need a way to only have a collision when the player walks into the coloured part of the texture, and not the transparent background.
I plan to handle collision as follows:
- Check if any sprites are in range of the player
- Do a rect bounding box collision test
- Do an accurate collision (Where I need help)
I don't mind advanced techniques, as I want to get this right with all my requirements in mind, but I'm not sure how to approach this. What techniques or even libraries to try. I know that I will probably need to create and store some kind of shape that accurately represents each sprite minus the transparent background.
I've read that per pixel is slow, so given my large levels and number of objects I don't think that would be suitable. I've also looked at Box2d, but haven't been able to find much documentation, or any examples of how to get it up and running with SFML.
© Game Development or respective owner