Allegro.cc - Online Community

Allegro.cc Forums » Programming Questions » problems with collision algorithm

This thread is locked; no one can reply to it. rss feed Print
problems with collision algorithm
Loki66
Member #17,089
May 2019

Hi everybody
I have been trying to make two circles that move and collide with each other and with the edges of the display.
the rebound algorithm is ok, but the collision algorithm is not
I searched on many sites and the result is that I can't get anything to work.
does anyone have a collision and bounce algorithm that works?
attached is the program crap I made. if you want to try it?
thank you all

Edgar Reynaldo
Major Reynaldo
May 2007
avatar

Elias
Member #358
May 2000

The easiest way to do this may be to use a third-party library like Chipmunk or Box2D. They are completely free to use like Allegro and already solve this (surprisingly involving) problem - and they likely solve it in a way that's way more performant than what any of us could come up with from scratch (you can have 1000ds of circles collide with no problem at all).

They also provide a lot more things but you can just ignore those (that's how I used Chipmunk before myself, just circle-circle and circle-line collision). You can also read their source code and just steal the algorithm - the license allows it :)

--
"Either help out or stop whining" - Evert

Go to: