SFML community forums

Help => General => Topic started by: Roy301 on March 23, 2016, 07:38:37 pm

Title: Programming a billard game
Post by: Roy301 on March 23, 2016, 07:38:37 pm
Hello,
I'm programming a litte billard game. I have the problem that i only know how to check for a collision between specific balls but i have already created a std::list for the balls. How can i  now check for collision between any balls in this list?

Source Code:

main.cpp
http://pastebin.com/wASBRcP3

Framework.cpp
http://pastebin.com/GtVs3ZBp
Framework.hpp
http://pastebin.com/YJnyA2ei

BallManager.cpp
http://pastebin.com/7xQd1wWp
BallManager.hpp
http://pastebin.com/0tXtHmes

Ball.cpp
http://pastebin.com/3QeTjwgx
Ball.hpp
http://pastebin.com/swruyw1C
Title: Re: Programming a billard game
Post by: Jesper Juhl on March 23, 2016, 08:03:52 pm
You may find this article of interest: http://www.gamasutra.com/view/feature/131424/pool_hall_lessons_fast_accurate_.php
Title: Re: Programming a billard game
Post by: ka0s420 on March 23, 2016, 08:57:24 pm
When checking collisions against balls in a list, the main problem ive encountered with this approach is that the ball you are checking will always be in collision with itself, so the first thing to do is remove the ball you are checking from the list, then iterate through said list checking against the balls in the list, then when you've done that, put the ball back in the list.