Elastic physics algorithm
Blitz3D Forums/Blitz3D Programming/Elastic physics algorithm
| ||
Hi, I was wondering if anyone would know how to do "elastic physics" (in 2D - well actually, 1D would suffice :))? I would have one object (x1,y1) and another (x2,y2) that's "hanging" from it with a virtual wire. It would fall down, but start bouncing back once it reaches a certain distance, then fall again and come up again, and eventually stop... and when the first object moves, it would have to either fall down again or be pulled up (depending if the object moved up or down). I can't find a way to do this realistically, but then again, I suck at physics. Anyone wanna help me? Thanks! |
| ||
I can take no credit for this as you can see .. it should help you though. Use the arrow keys ... |
| ||
Stevie G is a poet, and he doesn't know it! |
| ||
You do know that I'm Pam Ayres second cousin twice removed!! |
| ||
Oh man!! That code is awesome! I mean it's a really simple program but the elastic effect is fantastic. It would be great to convert this to a 3d demo. Could someone who has a good understanding of this sort of physics perhaps comment the code a bit for us. I would really love to understand how the code does what it does. |
| ||
max version (just a quick replace of some bits, no point ooping it up just for this lil example) |
| ||
I added this to GetInput() B3D If KeyDown( 57 ) p.particle = player\point p\x = 512 ;because screen is 1024 x 768 p\y = 384 EndIf BMax If KeyDown(key_space) p:particle = tmpplayer.point p.x = 512 p.y = 384 EndIf In case the triangle gets lost (happens often enough when playing with different parameters) keep space pressed until things have calmed down. Very useful Code snippet that you found, Stevie G - thanks! |