View Full Version : Translated 2d Ball collision code problem
arthurprs
08-09-2007, 10:02 PM
Hello i have translated the 2d ball collision code from flash (action script) taken from this page (http://www.emanueleferonato.com/2007/08/19/managing-ball-vs-ball-collision-with-flash/) to pacal, but code does not work..
see the code here (http://pastebin.com/f27395d92) or download the project with a binary included here (http://www.mediafire.com/?0vbulujssj3)
The collision is detected, but nothing is made :? i really don't know where is the problem
I revised the code three time and don't see anything wrong
Need some help please :?
User137
08-09-2007, 11:51 PM
Here's fix :D
http://pastebin.com/m640127ea
There was small typo in mass formula i think, and recursive for loop for collision is changed. Also replaced sqrt and power functions with built in hypot function for simplicity and speed.
...
After testing i noticed it still doesn't work well when gravity is applied with several more balls. That's when they start to move along edge of each other and slightly inside. Anyway i've never managed to make collision this realistic myself.
arthurprs
09-09-2007, 01:00 AM
Here's fix :D
http://pastebin.com/m640127ea
There was small typo in mass formula i think, and recursive for loop for collision is changed. Also replaced sqrt and power functions with built in hypot function for simplicity and speed.
...
After testing i noticed it still doesn't work well when gravity is applied with several more balls. That's when they start to move along edge of each other and slightly inside. Anyway i've never managed to make collision this realistic myself.
Yeah i compared the sources, its b1.mass + b1.masss :?
and the loop logic was broken
Thx :!: :)
Powered by vBulletin® Version 4.2.5 Copyright © 2024 vBulletin Solutions Inc. All rights reserved.