2D Fizzix

BlitzMax Forums/BlitzMax Programming/2D Fizzix

Chroma(Posted 2007) [#1]
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



Paul "Taiphoz"(Posted 2007) [#2]
can it handle other shapes yet ?


Chroma(Posted 2007) [#3]
Not yet. And there's a few slight problem with the resulting velocity that I haven't figured out yet.


Chroma(Posted 2007) [#4]
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.


nino(Posted 2007) [#5]
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.


Chroma(Posted 2007) [#6]
Updated with advanced velocity transfer with ball to ball collision. Still WIP but it's acting somewhat realistic now.


Chroma(Posted 2007) [#7]
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?


Grey Alien(Posted 2007) [#8]
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.


Chroma(Posted 2007) [#9]
Ok I tried that and i'm still getting the weird hopping when 3 balls are touching. It's probably something really simple.


Chroma(Posted 2007) [#10]
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...


nino(Posted 2007) [#11]
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.


Chroma(Posted 2007) [#12]
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.


nino(Posted 2007) [#13]
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