Algorithm for Direction Change upon Collision

Ender Nafi Elekcioglu endernafi at
Fri Nov 8 16:07:58 EST 2013

Scott, you’re the man :)

Interestingly, my collision code was exactly same as yours 
{I mean the intersect() section, swapping the directions and all},
that teeny, tiny line of *exit repeat* :))

It solved the whole thing.

I mean, almost...
There are some little glitches but nothing which can’t be handled.
Occasionally some pucks can escape off the screen boundaries
and again occasionally some pucks overlap each other.
Yet, after a while they release from themselves.

Performance is pretty good, too.
I could go up to 32 huge pucks at a 28 fps speed.
More than 32 pucks, refresh rate drops significantly.
But I need just ~20 particles and they will be tiny.

I still need to improve it by implementing Jim’s, Mark’s and Bernd’s suggestions.
There will be small sprite animations, thus I need efficiency and optimization.

Anyways, thank you very much.

-> one more thing:
Do you think falling back to C++, writing some code snippets for performance driven sections, could help this kinda situations?
Passing the locs to a dedicated C++ collision detector external and getting the result, maybe?
Although on a second thought, the intersect() itself is written in C++, right?
So, what are the odds that I can write more efficient / faster code than RunRev team?
Perhaps, this last question deserves a separate thread; still I wanna hear your { plural :) } thoughts…

Kindest Regards,

~ Ender Nafi

More information about the Use-livecode mailing list