2D Fizzix
BlitzMax Forums/BlitzMax Programming/2D Fizzix
| ||
NM...use Brucey's Chipmunk module instead. Updated: Version 0.05, Nov 2, 2007. Put in realistic velocity transfer on ball to ball collision. It's acting a lot like billiards now. Try it out. *** *** *** *** *** Here's something I've been messing around with. I think the order that I'm doing the collision check might be off though. It's got the basics of ball collision and it's somewhat cleanly coded. If anyone can add to this or improve it that'd be great. Feel free to use it. main.bmx Vec2D.bmx |
| ||
can it handle other shapes yet ? |
| ||
Not yet. And there's a few slight problem with the resulting velocity that I haven't figured out yet. |
| ||
Just updated this to fix collisions. Now the balls don't pass into one another at all. My only problems now are calculating the new body velocities after a collision. Also figure out the new rotation of the balls after a 2 ball collision. |
| ||
have you seen this? http://www.harveycartel.org/metanet/tutorials/tutorialA.html This guy has some great physics tutorials. His game "N" is really cool too. |
| ||
Updated with advanced velocity transfer with ball to ball collision. Still WIP but it's acting somewhat realistic now. |
| ||
Hmm...I'm getting unwanted random balls flying up. It's like they can't settle down and come to a rest. Can anyone see anything blatantly wrong with this code or maybe why the balls won't settle to a complete rest? |
| ||
probably due to floating point inaccuracies. I'd change the whole lot to doubles for a start as I'm told they are just as fast. Then try clamping the numbers to 0 when they get really small instead of letting them be just above zero but not quite. Also don't let them go negative if they started off positive etc. These are just suggestions based on problems I encoutered when coding a very similar minigame recently. |
| ||
Ok I tried that and i'm still getting the weird hopping when 3 balls are touching. It's probably something really simple. |
| ||
Updated again. Now each ball has it's own radius and mass. A small ball hit by a large one reacts according to the mass properties etc. There's still something up with the collisions getting hung up..kinda like lag. Not sure what it is. If anyone has any ideas... |
| ||
I had the same issue with a billiards game I was messing with. What I ended up doing is limiting the collisions to one per flip. This is obviously a hack but I couldn't be bothered figuring out how to fix it properly. I'll post the code somewhere later so as not to hijack your thread. Not sure it will help though because my approach was a lot different that yours. It's interesting to see how many solutions to one problem there are. |
| ||
Well we're talking about ball physics so I don't consider it a hijacking etc or a derail. Feel free to post what you like nino. |
| ||
This is very rough stuff using only graphics primitives and with some mysterious collision problems. Occasionally one of the balls will get stuck inside of a bumper or another ball but it was mainly to test physle.lib. Also not sure about the constants - they may be a little off. There is no english yet either (backspin not the language) but all in all a good start towards a billiards game. physle.lib.bmx billiards.bmx |