Scripting help - rope with certain length puzzle

Started by kaputtnik, Mon 23/04/2007 10:08:21

Previous topic - Next topic

kaputtnik

Hi guys.

I made up a really good puzzle which fits into my game quite perfectly, but sadly I don't have any idea how to script it; I am quite proficient with ags coding, this puzzle, however, is not a matter of proficiency but feasibility and creativity.

Okay. I want to implement a rope which is tied to a wall in one place. The rope has a certain length of...lets say...20 metres. The character can pick it up and drag it everywhere (over room borders), but only one direction makes sense, of course; he has to tie the other end to a pole or something like that. Do you think I could raw draw that rope, as a simple brown line? And if so, how? And how could the rope recognize that its 20 metres are exhausted?
I, object.

Rui 'Trovatore' Pires

You could use RawDraw to draw a line from the point where the rope is fixed to the player character when the player character is holding the rope. Then just check for the distance between the player character and the place where the rope is fixed.
Reach for the moon. Even if you miss, you'll land among the stars.

Kneel. Now.

Never throw chicken at a Leprechaun.

kaputtnik

#2
Oh, that's a good idea! I will try that, I think it could work, thanks!

edit: Okay, it works so far and in one room, but: Because these are screen, not room coordinates, I cannot calculate the proper distance when I am changing rooms. You know, I wanted the player to be able to drag the rope through several rooms. Is this possible at all?
I, object.

Rui 'Trovatore' Pires

Well, you'll need some rather specialised scripting in each room, then, I should think. In each room, if it's possible for the rope to be dragged all the way around, script accordingly, if not, script accordingly.

One thing you could consider would be to use room properties. As in:

"Rope Size:"

If in room X rope size was defined as [length of the screen], then code it so that it can go everywhere. Else, script accordingly.

Ugh, I couldn't have been more vague. :P Can't put it any clearer, though, if someone else can, please do.
Reach for the moon. Even if you miss, you'll land among the stars.

Kneel. Now.

Never throw chicken at a Leprechaun.

Khris

I'd do it using seperate walkable areas.
In the room's before fadein, check if the player is holding the end of the rope and turn on/off the part he can't reach.

About drawing the rope: You could even implement a rope that'll tighten once the player is about to be 20 metres away from the point it's tied to.
I'm pretty sure that a hanging rope takes the form of a parabola (a*x^2+b*x+c), even if the ends are at different heights.

Rui 'Trovatore' Pires

Reach for the moon. Even if you miss, you'll land among the stars.

Kneel. Now.

Never throw chicken at a Leprechaun.

kaputtnik

Yeah, I'll give that a try, shouldn't be too hard to implement. And I will finally overcome my RawDraw fears and do a *shiver* parabolic rope, check this out!
I, object.

FSi++

Quote from: KhrisMUC on Mon 23/04/2007 12:25:02
I'm pretty sure that a hanging rope takes the form of a parabola (a*x^2+b*x+c), even if the ends are at different heights.

Uh, actually no, it's not parabola, it's catenary...
http://en.wikipedia.org/wiki/Catenary

y(x) = a * cosh(x/a)

Don't ask me what the hell cosh is if you don't know; go to that wikipedia link instead :=

p.s. No worries, I myself got very surprised when I heard this the first time...

SMF spam blocked by CleanTalk