Functional Ladders

Learn how to make certain types of games and use gameEditor.

Functional Ladders

Postby Grynde » Thu Jun 20, 2013 11:54 pm

I would like to build off the previously discussed ladder topic here:http://game-editor.com/forum/viewtopic.php?f=6&t=5397
While that was definitely a fantastic launching pad, I ran into several issues. Mostly to do with yvelocity.

1. If you jumped, the yvelocity served as a one way elevator of sorts.
2. If you dropped onto a ladder, the yvelocity would continue to calculate until you hit ground.
3. You would immediately begin to fall if you released your climb button.

So let's begin shall we?

Create a var for your ladder.

First we need to add gravity under our player's draw actor. With a very important if statement.

Code: Select all
if (ladder==0)
{
yvelocity=yvelocity+0.9;
}

===============================================================================================================
Next, we create a new wire-frame actor named ladder_box and then add a collision between your player and the ladder_box.

Player->Collision Event->Any side of ladder_box->repeat->Script Editor
Code: Select all
char*key=GetKeyState();
if(key[KEY_UP]==1)
{
ladder=1;
jump=0;
yvelocity=0;
}
if(key[KEY_DOWN]==1)
{
ladder=1;
jump=0;
yvelocity=0;
}


What we've done here is to make it that once the collision occurs, your player will ignore the ladder all together until either UP or DOWN has been pressed, also we have temporarily disabled the jump.
===============================================================================================================
Next, create a collision finish with the aforementioned ladder_box.

Player->Collision Finish Event->ladder_box->Script Editor
Code: Select all
ladder=0;
jump=1;


With this done, this allows us to break free of the ladder and not climb forever, also as we fall off the ladder, we can now jump again.
====================================================================================================================
Now, add your Key Down events.

Player->Key Down->(up, At least one key is pressed, repeat)
Code: Select all
if(ladder==1)
{y = y-5;}

Player->Key Down->(down, At least one key is pressed, repeat)
Code: Select all
if(ladder==1)
{y = y+5;}


Your finished!

Now just add a fancy (or not so fancy) ladder sprite inside your ladder_box and climb dem lebels! :D
Attachments
ladder Tut.zip
(161.76 KiB) Downloaded 232 times
Playing a game is the voluntary attempt to overcome unnecessary obstacles.
-Bernard Suits
User avatar
Grynde
 
Posts: 21
Joined: Fri Apr 26, 2013 12:41 pm
Location: Virginia
Score: 1 Give a positive score

Return to Tutorials

Who is online

Users browsing this forum: No registered users and 1 guest