Making a Ladder on Key Down Event: Button Key Up

Talk about making games.

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

make a variable called af,
on the animation finish event of "UP"(ladder climbing animation)
Code: Select all
af = 0;

make another variable called CLIMB
and use this code for the repeated collision event of the player colliding with the ladder(add this for the player)
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;

:D
(I did a redo of the code here)
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 » Fri May 11, 2007 1:05 am

Then you didnt describe that good. Because if I leave my original gravity in, he'll bounce.
ShingingDB
 
Posts: 43
Joined: Sun Apr 01, 2007 1:31 am
Score: 0 Give a positive score

Postby ShingingDB » Fri May 11, 2007 1:07 am

Didn't see your new post. Let me test it.
ShingingDB
 
Posts: 43
Joined: Sun Apr 01, 2007 1:31 am
Score: 0 Give a positive score

Postby Sgt. Sparky » Fri May 11, 2007 1:28 am

allrighty! :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 » Sun May 13, 2007 6:05 pm

Yay! It works. Now how do I make it so that, the player goes up when you press Key Up, and the player climbs down when you press Key Down?

Sorry if I'm asking you for alot of work.
ShingingDB
 
Posts: 43
Joined: Sun Apr 01, 2007 1:31 am
Score: 0 Give a positive score

Postby Sgt. Sparky » Mon May 14, 2007 1:27 am

just change your code on the collision event of the ladder to,
Code: Select all
char*key=GetKeyState();
CLIMB = 1;
if(key[KEY_UP] == 1 && key[KEY_DOWN] == 0)
{
    if(af == 0) {
    af = 1;
    ChangeAnimation("Event Actor", "UP", FORWARD);
                     }
    y -= 3;
}
if(key[KEY_UP] == 0 && key[KEY_DOWN] == 1)
{
    if(af == 0) {
    af = 1;
    ChangeAnimation("Event Actor", "DOWN", FORWARD);
                     }
    y += 3;
}

:D
it is not to much work at all! :)
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 14, 2007 1:37 am

Err. It works, but on that platform, I have a filled region acting as the land for the platform. It only collides with the actor and stops them for the top part. Is there a way for it to ignore that when it's key down?
ShingingDB
 
Posts: 43
Joined: Sun Apr 01, 2007 1:31 am
Score: 0 Give a positive score

Postby Sgt. Sparky » Mon May 14, 2007 1:49 am

on collision of the filled actor,
Code: Select all
if(CLIMB == 0)PhysicalResponse(MOVE_EVENT_ACTOR_ONLY, USE_CALCULATED_MASS, 1.000000, 1.000000, 0.300000, 1.000000);

: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 14, 2007 1:57 am

Sgt. Sparky wrote:on collision of the filled actor,
Code: Select all
if(CLIMB == 0)PhysicalResponse(MOVE_EVENT_ACTOR_ONLY, USE_CALCULATED_MASS, 1.000000, 1.000000, 0.300000, 1.000000);

:D



Ok it works, a little... When you walk around on the other sides of the platform thats not on top of the ladder, its normal collision. But if you walk over the ladder while still on the platform, you fall down. I only want him to fall down if you press down.
ShingingDB
 
Posts: 43
Joined: Sun Apr 01, 2007 1:31 am
Score: 0 Give a positive score

Postby Sgt. Sparky » Mon May 14, 2007 3:55 am

oi, sorry it took so long to reply! :(
I was busy with halo kitty (halo + hello kitty).
here is the new code to change to on the collision of the platform,
Code: Select all
char*key=GetKeyState();
if(key[KEY_DOWN] == 0)PhysicalResponse(MOVE_EVENT_ACTOR_ONLY, USE_CALCULATED_MASS, 1.000000, 1.000000, 0.300000, 1.000000);

: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 14, 2007 4:26 am

Sgt. Sparky wrote:oi, sorry it took so long to reply! :(
I was busy with halo kitty (halo + hello kitty).
here is the new code to change to on the collision of the platform,
Code: Select all
char*key=GetKeyState();
if(key[KEY_DOWN] == 0)PhysicalResponse(MOVE_EVENT_ACTOR_ONLY, USE_CALCULATED_MASS, 1.000000, 1.000000, 0.300000, 1.000000);

:D


YAY It works. Thank you sooo much. I wish I have your knowledge so I wont have to bother you all the time :D

Also wow Halo Kitty xD
ShingingDB
 
Posts: 43
Joined: Sun Apr 01, 2007 1:31 am
Score: 0 Give a positive score

Postby Sgt. Sparky » Mon May 14, 2007 4:45 am

ShingingDB wrote:Also wow Halo Kitty xD

here is an image,
I think I may change it to look better. :)
(screen shot coming soon!)
:lol:
Attachments
HALO_KITTY_LEFT2.gif
: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

Re: Making a Ladder on Key Down Event: Button Key Up

Postby abitheone » Mon Jul 20, 2009 6:14 pm

i was working on a 'ladder' program too, and came across this problem:
so when the player collides with the ladder actor, he should be able to climb up when he presses the up button. but in this case, its not necessarily the middle of the ladder (in the x direction). the player touches the left boundary of the ladder and thus he collides. he starts climbing up, but visually its not right.

how do i make him climb, only when he is in the center of the ladder in the x direction?
abitheone
 
Posts: 1
Joined: Thu Jul 16, 2009 11:35 am
Score: 0 Give a positive score

Re: Making a Ladder on Key Down Event: Button Key Up

Postby skydereign » Mon Jul 20, 2009 9:12 pm

I haven't tested this, but to do that, assuming the ladder is straight up, the ladder's x will be in the middle of the ladder. So if the player's x is the same, it will be in the middle.
Code: Select all
char*key=GetKeyState();
if(x == collide.x)
{
  CLIMB = 1;
  if(key[KEY_UP] == 1)
  {
      if(af == 0) {
      af = 1;
      ChangeAnimation("Event Actor", "UP", FORWARD);
                       }
      y -= 3;
  }
}


This may be too strict for you tastes, if so I can fix that, not sure on the size of the ladder and player.
User avatar
skydereign
 
Posts: 3510
Joined: Mon Jul 28, 2008 8:29 am
Score: 589 Give a positive score

Re: Making a Ladder on Key Down Event: Button Key Up

Postby DST » Mon Jul 20, 2009 10:08 pm

Asking the player to be dead center may be difficult, especially if you use the ladder quickly (when you are being chased).

Instead, just ask the player to be close, then suck the player to the correct spot.

Code: Select all
if(abs(collide.x-x)<8){  //if player is within 8 pixels either direction
player.x=collide.x;       //move player to ladder center
begin climbing stuff;
}


If it looks unnatural, just reduce the size of the check from 8 to 4. If its too much the player jerks, if its too little, the ladder is difficult to use.
It's easier to be clever than it is to be kind.
http://www.lostsynapse.com
http://www.dstgames.com
User avatar
DST
 
Posts: 1117
Joined: Sun Apr 15, 2007 5:36 pm
Location: 20 minutes into the future
Score: 151 Give a positive score

Previous

Return to Game Development

Who is online

Users browsing this forum: No registered users and 1 guest

cron