Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Collision detect (advanced) for my SFML game  (Read 1703 times)

0 Members and 1 Guest are viewing this topic.

Tigre Pablito

  • Full Member
  • ***
  • Posts: 225
    • View Profile
    • Email
Collision detect (advanced) for my SFML game
« 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

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 10821
    • View Profile
    • development blog
    • Email
Re: Collision detect (advanced) for my SFML game
« Reply #1 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. ;)
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

JayhawkZombie

  • Jr. Member
  • **
  • Posts: 76
    • View Profile
Re: Collision detect (advanced) for my SFML game
« Reply #2 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

Tigre Pablito

  • Full Member
  • ***
  • Posts: 225
    • View Profile
    • Email
Re: Collision detect (advanced) for my SFML game
« Reply #3 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

 

anything