Page 2 of 2

PostPosted: Thu May 10, 2007 12:10 am
by Sgt. Sparky
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)

PostPosted: Fri May 11, 2007 1:05 am
by ShingingDB
Then you didnt describe that good. Because if I leave my original gravity in, he'll bounce.

PostPosted: Fri May 11, 2007 1:07 am
by ShingingDB
Didn't see your new post. Let me test it.

PostPosted: Fri May 11, 2007 1:28 am
by Sgt. Sparky
allrighty! :D

PostPosted: Sun May 13, 2007 6:05 pm
by ShingingDB
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.

PostPosted: Mon May 14, 2007 1:27 am
by Sgt. Sparky
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! :)

PostPosted: Mon May 14, 2007 1:37 am
by ShingingDB
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?

PostPosted: Mon May 14, 2007 1:49 am
by Sgt. Sparky
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

PostPosted: Mon May 14, 2007 1:57 am
by ShingingDB
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.

PostPosted: Mon May 14, 2007 3:55 am
by Sgt. Sparky
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

PostPosted: Mon May 14, 2007 4:26 am
by ShingingDB
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

PostPosted: Mon May 14, 2007 4:45 am
by Sgt. Sparky
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:

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

PostPosted: Mon Jul 20, 2009 6:14 pm
by abitheone
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?

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

PostPosted: Mon Jul 20, 2009 9:12 pm
by skydereign
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.

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

PostPosted: Mon Jul 20, 2009 10:08 pm
by DST
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.