SFML community forums

Help => General => Topic started by: Tigre Pablito on April 22, 2017, 02:24:39 am

Title: Collision detect (advanced) for my SFML game
Post by: Tigre Pablito on April 22, 2017, 02:24:39 am
Hello, Ladies and Guys

Is there any SFML function or way to detect collision between to objects that are not horizontal or vertical Rectangles? Or one that a member has already done? I suposse I can say that the objects could be inclined Rectangles at most. Sorry if this is a stupid question, or if it would take a great alghoritmic job (what is what I'm trying to avoid).

For those (if there are) who have seen my poor Space Shooter game that has a problem in older PCs, the inclined Rectangles are the enemy missiles, and some ships. Currently the collision check function es totally cartesian and I think that is not good.

Actually, I have just uploaded an update of the app (has 2 levels, still in development)

I would appreciate any help
Title: Re: Collision detect (advanced) for my SFML game
Post by: eXpl0it3r on April 22, 2017, 07:36:41 pm
SFML doesn't provide anything like that, but you should be able to find general resources talking about this with some simple googling. Key word that might help is: non axis aligned bound box

Keep in mind though, that AABB can still work, even if the accuracy isn't 100%.
And finally, you can also just sit down with a pen and a piece of paper and think through the problem geometrically and mathematically. ;)
Title: Re: Collision detect (advanced) for my SFML game
Post by: JayhawkZombie on April 23, 2017, 02:10:50 am
If you do not wish to do it yourself, you can use something like Box2D: https://github.com/erincatto/Box2D
Title: Re: Collision detect (advanced) for my SFML game
Post by: Tigre Pablito on April 23, 2017, 04:39:46 pm
Hi eXpl0it3r, JayhawkZombie

I googled non AABB and found something that seems it works

Then I'll take some time to see about Box2D

Thanks