pucks collide

Frans Schoffelen frans at knowlegistics.com
Fri Nov 8 06:28:16 EST 2013


On 08.11.2013, at 12:00, use-livecode-request at lists.runrev.com wrote:

> The biggest problem here is that "finished colliding" is a property of a collision rather than any individual pucks. It gets really messy with multiple collisions.
> 
>>> Any quick ideas, anyone?
> 
> As you may have guessed, this isn't an uncommon problem. A couple of ways of handling this off the top of my head:
> 1) If your pucks are circles you should be figuring out the vector between the centre of the circles when they intersect as part of working out the correct bounce angle. If you have this vector then you can also work out whether the current direction of each puck is taking it towards or away from the one it is colliding with and act accordingly. This should handle the multiple collision situation most graciously.
> 
> 2) When two pucks collide, don't only change their velocities but also their positions, so that they are not overlapping. If you do this make sure you move both by half the overlapping distance (simple version), or proportional to their velocities (more realistic version). Obviously this involves moving both pucks from the one intersect test.


Hi,

you may want to have a look at the excellent algorithms provided in the AE engine from Malte Brill.

Cheers

Frans


Frans Schoffelen
http://knowlegistics.com  // Software & Sound // Makers of "Die Waldfibel 1.0" , "Beste Reste" and  "Jolly Dolly"  on Appstores







More information about the use-livecode mailing list