Swinging Rope help

BlitzPlus Forums/BlitzPlus Programming/Swinging Rope help

Nicstt(Posted 2005) [#1]
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)


Rob Farley(Posted 2005) [#2]
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.


CS_TBL(Posted 2005) [#3]
Could that swings be done using 1 bezier-curve while changing the end point and the end-control-point btw?


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


Nicstt(Posted 2005) [#5]
What's it for? A pitfall type rope?



yup

thanks some great ideas there, sine - yuck

guess ill start working on it, thanks again


VIP3R(Posted 2005) [#6]
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


CS_TBL(Posted 2005) [#7]
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? :)




CS_TBL(Posted 2005) [#8]
ps. no doubt it isn't fool-proof ^_^


Najdorf(Posted 2005) [#9]
here you go




CS_TBL(Posted 2005) [#10]
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
?


Najdorf(Posted 2005) [#11]
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


Nicstt(Posted 2005) [#12]
Thanks again for all the input.

Working on rope atm:)