Making a Ladder on Key Down Event: Button Key Up

Talk about making games.

Making a Ladder on Key Down Event: Button Key Up

Postby ShingingDB » Sun May 06, 2007 4:05 am

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.
ShingingDB
 
Posts: 43
Joined: Sun Apr 01, 2007 1:31 am
Score: 0 Give a positive score

Postby Sgt. Sparky » Sun May 06, 2007 4:16 am

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. :)
Image
Random Links:
viewtopic.php?p=19474#19474
Right now (10/14/2009) I'm working on some C++ projects, but I might be able to help if you have some Game Editor questions. :)
User avatar
Sgt. Sparky
 
Posts: 1850
Joined: Sat Oct 07, 2006 5:28 pm
Location: Somewhere out there, beneath the pale blue sky...
Score: 236 Give a positive score

Postby ShingingDB » Sun May 06, 2007 4:32 am

It says:

Error Expected Line 7: )
Error Expected Line 87: }
ShingingDB
 
Posts: 43
Joined: Sun Apr 01, 2007 1:31 am
Score: 0 Give a positive score

Postby ShingingDB » Sun May 06, 2007 4:34 am

And no it does not work....
ShingingDB
 
Posts: 43
Joined: Sun Apr 01, 2007 1:31 am
Score: 0 Give a positive score

Postby Sgt. Sparky » Sun May 06, 2007 4:44 am

did you copy and paste my code?
Image
Random Links:
viewtopic.php?p=19474#19474
Right now (10/14/2009) I'm working on some C++ projects, but I might be able to help if you have some Game Editor questions. :)
User avatar
Sgt. Sparky
 
Posts: 1850
Joined: Sat Oct 07, 2006 5:28 pm
Location: Somewhere out there, beneath the pale blue sky...
Score: 236 Give a positive score

Postby ShingingDB » Sun May 06, 2007 6:58 pm

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.
ShingingDB
 
Posts: 43
Joined: Sun Apr 01, 2007 1:31 am
Score: 0 Give a positive score

Postby Sgt. Sparky » Mon May 07, 2007 12:55 am

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 )
Image
Random Links:
viewtopic.php?p=19474#19474
Right now (10/14/2009) I'm working on some C++ projects, but I might be able to help if you have some Game Editor questions. :)
User avatar
Sgt. Sparky
 
Posts: 1850
Joined: Sat Oct 07, 2006 5:28 pm
Location: Somewhere out there, beneath the pale blue sky...
Score: 236 Give a positive score

Postby ShingingDB » Mon May 07, 2007 4:15 am

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.
ShingingDB
 
Posts: 43
Joined: Sun Apr 01, 2007 1:31 am
Score: 0 Give a positive score

Postby Sgt. Sparky » Tue May 08, 2007 12:33 am

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
Image
Random Links:
viewtopic.php?p=19474#19474
Right now (10/14/2009) I'm working on some C++ projects, but I might be able to help if you have some Game Editor questions. :)
User avatar
Sgt. Sparky
 
Posts: 1850
Joined: Sat Oct 07, 2006 5:28 pm
Location: Somewhere out there, beneath the pale blue sky...
Score: 236 Give a positive score

Postby ShingingDB » Tue May 08, 2007 1:56 am

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.
ShingingDB
 
Posts: 43
Joined: Sun Apr 01, 2007 1:31 am
Score: 0 Give a positive score

Postby ShingingDB » Tue May 08, 2007 1:58 am

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.....
ShingingDB
 
Posts: 43
Joined: Sun Apr 01, 2007 1:31 am
Score: 0 Give a positive score

Postby Sgt. Sparky » Tue May 08, 2007 2:39 am

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
Image
Random Links:
viewtopic.php?p=19474#19474
Right now (10/14/2009) I'm working on some C++ projects, but I might be able to help if you have some Game Editor questions. :)
User avatar
Sgt. Sparky
 
Posts: 1850
Joined: Sat Oct 07, 2006 5:28 pm
Location: Somewhere out there, beneath the pale blue sky...
Score: 236 Give a positive score

Postby Sgt. Sparky » Tue May 08, 2007 2:39 am

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
Image
Random Links:
viewtopic.php?p=19474#19474
Right now (10/14/2009) I'm working on some C++ projects, but I might be able to help if you have some Game Editor questions. :)
User avatar
Sgt. Sparky
 
Posts: 1850
Joined: Sat Oct 07, 2006 5:28 pm
Location: Somewhere out there, beneath the pale blue sky...
Score: 236 Give a positive score

Postby ShingingDB » Wed May 09, 2007 10:54 pm

Ok so I take out the gravity. But after I jump after I have climbed, I just float up.
ShingingDB
 
Posts: 43
Joined: Sun Apr 01, 2007 1:31 am
Score: 0 Give a positive score

Postby Sgt. Sparky » Thu May 10, 2007 12:08 am

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.
Image
Random Links:
viewtopic.php?p=19474#19474
Right now (10/14/2009) I'm working on some C++ projects, but I might be able to help if you have some Game Editor questions. :)
User avatar
Sgt. Sparky
 
Posts: 1850
Joined: Sat Oct 07, 2006 5:28 pm
Location: Somewhere out there, beneath the pale blue sky...
Score: 236 Give a positive score

Next

Return to Game Development

Who is online

Users browsing this forum: No registered users and 1 guest