Hello to all. I'm developing a game in C++ and SFML. I need help with a part of it.
I have 2 circles. One of them you control with the mouse and the other one should move on its own, but it doesn't hit the first circle properly. Let me explain.
The second circle has a direction (in degrees, counting clockwise from North) and speed. It successfully bounces off the borders of the window in a realistic fashion. Now here comes the wrong part.
Whenever the second circle hits the first one, it should bounce off in a realistic fashion, as well.
After at least 10 different tries to calculate a formula for the new direction value, I gave up. The 2nd circle would either bounce off in a completely wrong direction, get stuck in the 1st one or, very strangely, start rotating round it.
Now, I should mention that I have a very light understanding of trigonometry. I have never studied it in school (that'll be happening next year) and I tried to make out as much as I could from the Wikipedia article on trigonometric functions.
I really hope someone could help me out with this, as it would solve pretty much all the problems with my game (except for speed calculation, but I have an idea about that).
Thanks in advance.
I have 2 circles. One of them you control with the mouse and the other one should move on its own, but it doesn't hit the first circle properly. Let me explain.
The second circle has a direction (in degrees, counting clockwise from North) and speed. It successfully bounces off the borders of the window in a realistic fashion. Now here comes the wrong part.
Whenever the second circle hits the first one, it should bounce off in a realistic fashion, as well.
After at least 10 different tries to calculate a formula for the new direction value, I gave up. The 2nd circle would either bounce off in a completely wrong direction, get stuck in the 1st one or, very strangely, start rotating round it.
Now, I should mention that I have a very light understanding of trigonometry. I have never studied it in school (that'll be happening next year) and I tried to make out as much as I could from the Wikipedia article on trigonometric functions.
I really hope someone could help me out with this, as it would solve pretty much all the problems with my game (except for speed calculation, but I have an idea about that).
Thanks in advance.