Page 1 of 2

Making a Ladder on Key Down Event: Button Key Up

PostPosted: Sun May 06, 2007 4:05 am
by ShingingDB
In my game, I need to create a ladder to get up to a higher platform. The player has to be standing in front of the ladder directly, then press Up to climb up. When the player presses up, it'll change the animation into a climbing animation and after he's done climbing, he'll go back to the original animation.

PostPosted: Sun May 06, 2007 4:16 am
by Sgt. Sparky
make a variable called af,
on the collision with the ladder:
Code: Select all
char*key=GetKeyState();
if(key[KEY_UP] == 1)
{
    if(af == 0) {
    af = 1;
    ChangeAnimation("Event Actor", "UP", FORWARD 
                     }
    y -= 3;
}

on the animation finish event of up(for the player)
Code: Select all
af = 0;

:D
I hope that helps,
if you need any more help let me know. :)

PostPosted: Sun May 06, 2007 4:32 am
by ShingingDB
It says:

Error Expected Line 7: )
Error Expected Line 87: }

PostPosted: Sun May 06, 2007 4:34 am
by ShingingDB
And no it does not work....

PostPosted: Sun May 06, 2007 4:44 am
by Sgt. Sparky
did you copy and paste my code?

PostPosted: Sun May 06, 2007 6:58 pm
by ShingingDB
Yes... Ok I fixed the code a little bit. Added the ) And its fix. But then when I press UP on the ladder, the player wont go up at all.

PostPosted: Mon May 07, 2007 12:55 am
by Sgt. Sparky
hmmm... :(
Code: Select all
char*key=GetKeyState();
if(key[KEY_UP] == 1)
{
    if(af == 0) {
    af = 1;
    ChangeAnimation("Event Actor", "UP", FORWARD);
                     }
    y -= 3;
}

try that.
make sure you add this event for the player and collision repeat is enabled.
:D
(fixed the missing ')' and ';' :D )

PostPosted: Mon May 07, 2007 4:15 am
by ShingingDB
Ok.. It barely works. When you press up, the player just bounces xD. He bounces instead of climbing onto the ladder and staying there.

Also I think you might think when you press Up on the ladder, the player just goes all the way up automatically. But I'm talking about the player pressing up, the climbs up, if the player lets go of the UP button, the actor will stay there on the ladder.

Right now it the player just bounces up and down.

PostPosted: Tue May 08, 2007 12:33 am
by Sgt. Sparky
hmmm,
make another variable called CLIMB (with the others I told you to make)
and use this code for the ladder stuff,
Code: Select all
char*key=GetKeyState();
CLIMB = 1;
if(key[KEY_UP] == 1)
{
    if(af == 0) {
    af = 1;
    ChangeAnimation("Event Actor", "UP", FORWARD);
                     }
    y -= 3;
}

and for your draw actor event that has the gravity stuff,
Code: Select all
if(CLIMB == 0)yvelocity += 1;

and on collision finish event of the ladder,
Code: Select all
CLIMB = 0;

:)
that has to work! :D

PostPosted: Tue May 08, 2007 1:56 am
by ShingingDB
What do I do with the

CLIMB = 0;

collision event with ladder. Is it ladder colliding with the player, or is it the player colliding with the ladder.

PostPosted: Tue May 08, 2007 1:58 am
by ShingingDB
Ok I just added the
CLIMB = 0; to the ladder.

And he still bounces!!!!! Ahh crud...

Edit: I took out my original gravity thing. Now when I press Up on the ladder, I climb yay! But then there's a problem..... There's no gravity. After you've climb to the top of the ladder, then jump, theres no gravity and takes you to space.....

PostPosted: Tue May 08, 2007 2:39 am
by Sgt. Sparky
ShingingDB wrote:What do I do with the

CLIMB = 0;

collision event with ladder. Is it ladder colliding with the player, or is it the player colliding with the ladder.

look at my post,
it tells you. xD

PostPosted: Tue May 08, 2007 2:39 am
by Sgt. Sparky
ShingingDB wrote:Ok I just added the
CLIMB = 0; to the ladder.

And he still bounces!!!!! Ahh crud...

Edit: I took out my original gravity thing. Now when I press Up on the ladder, I climb yay! But then there's a problem..... There's no gravity. After you've climb to the top of the ladder, then jump, theres no gravity and takes you to space.....

you will not get that problem if you use my code how I said. :D

PostPosted: Wed May 09, 2007 10:54 pm
by ShingingDB
Ok so I take out the gravity. But after I jump after I have climbed, I just float up.

PostPosted: Thu May 10, 2007 12:08 am
by Sgt. Sparky
ShingingDB wrote:Ok so I take out the gravity. But after I jump after I have climbed, I just float up.

do not take out the gravity.
just use the code how I told you,
it works if you use it exactly as I said. :D
if I did not descibe it good let me know.