Swinging Rope help
BlitzPlus Forums/BlitzPlus Programming/Swinging Rope help
| ||
Anyone out there got any suggestions for making a rope swing realistically. I thought of making it up from very small image sections. However, if there is a formula to calculate this effect i would be very happy(maybe) |
| ||
Now this depends on how realistic you want it... What's it for? A pitfall type rope? If so you probably don't want it that realistic. An easy way to make something that 'looks about right' is: Draw a bunch of arcs from the pivot point for your segments. ![]() Now as you move to the lower segments you move along the arc faster than the higher ones, this will give the impression of the end flailing. You'd move them using a sine wave so they slow at the ends and reach full speed in the middle. This is not accurate at all, this is not realistic at all, but it looks about right for a game. |
| ||
Could that swings be done using 1 bezier-curve while changing the end point and the end-control-point btw? |
| ||
Not a bad idea CS_TBL, you could use the following spline code using two points and modify it so that the end point moves back and forth... http://www.blitzmax.com/codearcs/codearcs.php?code=1100 Might be a bit overcomplicated for a rope but it's worth trying. |
| ||
What's it for? A pitfall type rope? yup thanks some great ideas there, sine - yuck guess ill start working on it, thanks again |
| ||
If you're looking for a pitfall type rope then this code will be of interest to you as well :) Pitfall II remake source by WolRon... http://www.blitzmax.com/codearcs/codearcs.php?code=1224 |
| ||
Out of boredom I made a few rope-functions, bankbased, but no user should be bothered with that.. (I think) it's also based on those circles btw.. The example app says it all .. The rope-swing could be a bit better.. the upper-part of the ropes ain't swinging at all. Ahwell, someone who wants to improve it, within the current structure? :) |
| ||
ps. no doubt it isn't fool-proof ^_^ |
| ||
here you go |
| ||
The effect looks great! But the source looks a bit painful to read, for me :\ doesn't look much stand-alone, or self-contained.. it's simply 'the routine', everywhere. Would it be possible to - get rid of *all* globals and dims - make stand-alone selfcontained 'blackbox' functions ? |
| ||
ok, I'll explain you the algorithm in words: at each frame you move the balls as there was no link between them. Then, every frame, you try to get the balls back linked: to do this you (*) use an algorithm that for every couple of linked balls, shifts them closer by an amount proportional to their distance. You need to calculate all the shifts for all couples before you apply them. Moreover, all this must be repeated for 30-40 times every frame(i.e.goto *). then you update the speed of of each ball according to the movement it did in the last frame sorry I'm not good at modular design, try to see if you can get it a "black box" hey, I remember I clallenged people here to do it, and botbuilder came up with a solution that is probably coded much better than mine: check it out! http://blitzmax.com/Community/posts.php?topic=43242&hl=chain |
| ||
Thanks again for all the input. Working on rope atm:) |