Page 1 of 1

Swinging ropes in games

Posted: Wed Feb 14, 2018 9:37 am
by Ralf
Maybe we could talk more about programming tricks :)

So some games have swinging ropes forth and back like here:

Image

On Spectrum the obvious example is Jet Set Willy engine:

Image

So how do you implement such rope in your code? Is it a complicated stuff involving math, sines and cosines or is there some trick to do it in a simple way?

I suppose the lame way is to make the rope a straight line but it seems that most game do better than that.

Re: Swinging ropes in games

Posted: Wed Feb 14, 2018 11:02 am
by Nomad
To be honest I never think of that till now but I agree it must be a difficult thing to implement even a regular repeating arc movement.

I guess the follow up question would be, could the rope movement have an irregular arc, deformation?

Re: Swinging ropes in games

Posted: Wed Feb 14, 2018 11:09 am
by Sokurah
Here's how it was done in Jet Set Willy;

http://www.oocities.org/andrewbroad/spe ... #jsw-ropes

Re: Swinging ropes in games

Posted: Wed Feb 14, 2018 11:24 am
by Morkin
Ralf wrote: Wed Feb 14, 2018 9:37 am
I suppose the lame way is to make the rope a straight line but it seems that most game do better than that.
Ah yeah, Hunchback did that didn't it?

Of course there's always Juan's favourite, Jungle Fever... :lol:

Re: Swinging ropes in games

Posted: Wed Feb 14, 2018 11:54 am
by MatGubbins
Jack The Nipper 2 - coconut capers- has a very nice rope to swing on

Re: Swinging ropes in games

Posted: Wed Feb 14, 2018 12:03 pm
by Rorthron
Sokurah wrote: Wed Feb 14, 2018 11:09 am Here's how it was done in Jet Set Willy;

http://www.oocities.org/andrewbroad/spe ... #jsw-ropes
The JSW rope has a kink in it, so the movement isn't completely right.

Re: Swinging ropes in games

Posted: Wed Feb 14, 2018 12:20 pm
by Sokurah
Rorthron wrote: Wed Feb 14, 2018 12:03 pm The JSW rope has a kink in it, so the movement isn't completely right.
I wasn't suggesting you should copy the code - just look at how it was done and perhaps come up with a new similar way.

Re: Swinging ropes in games

Posted: Wed Feb 14, 2018 1:38 pm
by Juan F. Ramirez
Morkin wrote: Wed Feb 14, 2018 11:24 am
Of course there's always Juan's favourite, Jungle Fever... :lol:
Aaahh, Jungle Fever, memories!

Great game to reduce my self-steem! :mrgreen:

Re: Swinging ropes in games

Posted: Wed Feb 14, 2018 1:57 pm
by Ralf
Thanks for that link.

So Matthew Smith is using some precalculated table for the points makeing the rope. Actually I could guess it.

Re: Swinging ropes in games

Posted: Wed Feb 14, 2018 2:05 pm
by hikoki
[youtube]https://youtu.be/3JcQ4IOl1OA[/youtube]

[youtube]https://youtu.be/xZEyLEEGS0Q[/youtube]

Re: Swinging ropes in games

Posted: Wed Feb 14, 2018 2:10 pm
by Joefish
Ah, it's not the point positions. It's the offset from the point immediately above. So you start at the top point, then the next point is +0 horizontally, +6 downwards, and so on through the table until you've plotted enough points.

Then if you start a little bit later in the table, so a little offset sneaks in at the bottom, and that works its way up to the top until the whole chain of points is offset to one side or the other.

And since it's a table, a random bit of wobblyness can be added that appears to ripple up then back down the rope near the end of the swing.

Re: Swinging ropes in games

Posted: Thu Feb 15, 2018 11:11 am
by RMartins
A reference Lookup table would be the obvious choice, for performance concerns.

Re: Swinging ropes in games

Posted: Sun Feb 18, 2018 7:02 pm
by Jonathan
Egghead Goes to Town used a big table of coordinates for speed, all pre-calculated in Sinclair BASIC. It was quite expensive but seeing as the screens were very efficiently stored I figured it was affordable.

Re: Swinging ropes in games

Posted: Sun Feb 18, 2018 8:55 pm
by R-Tape
Jonathan wrote: Sun Feb 18, 2018 7:02 pm Egghead Goes to Town used a big table of coordinates for speed, all pre-calculated in Sinclair BASIC. It was quite expensive but seeing as the screens were very efficiently stored I figured it was affordable.
There's a flaw somewhere though, you've gone against Spectrum best practise by not having a rope with 75% unfair collision.

Re: Swinging ropes in games

Posted: Sun Feb 18, 2018 9:07 pm
by Ralf
Egghead Goes to Town used a big table of coordinates for speed, all pre-calculated in Sinclair BASIC
Wow, calculating data in Spectrum Basic in 2017 is certainly retro :)

Personally when I needed once some precalculated data for my game, I used Excel. Not very cool, I suppose ;)

By the way, welcome to the forums, Jonathan !