
11-14-2010, 12:25 AM
|
|
One More Time
|
 |
Join Date: Aug 2010
Location: TN, USA
Posts: 631
|
|
PHP Code:
//#CLIENTSIDE
function onCreated()
{
this.ladderImg = <ladderIMG>; // Replace <ladderIMG> with the ladder image you want to use surrounded by quotes
this.ladderIdle = <ladderANIidle>; // Replace <ladderANIidle> with the idle ladder gani you want to use, surrounded by quotes
this.ladderWalk = <ladderANIwalk>; // Replace <ladderANIwalk> with the walk/moving ladder gani you want to use, surrounded by quotes
setImg( this.ladderImg); // Sets the ladder image
setshape( 1, getimgwidth( this.ladderImg), getimgheight( this.ladderImg)); // This sets the shape of the ladder so the client can detect it better in my opinion
onTimeout(); // This will start the onTimeout Loop
}
function onTimeout()
{
if ( player.x + 1.5 in | this.x, this.x + ( getimgwidth( this.ladderImg) / 16)| &&
player.y + 2.0 in | this.y, this.y + ( getimgheight( this.ladderImg) / 16)|) // Checks to see if the player is on the ladder
{
player.onLadder = true; // We'll set this flag so we can know later on that the player is on the ladder
setani( this.ladderIdle, NULL); // Sets the players gani to the idle ladder gani
//You could also do player.dir = 0; and not use special ganis altogether, just us 'idle' and 'walk' (or 'walkslow')
}
else
player.onLadder = false; // This tells the script later on that the player is NOT on the ladder
if ( player.onLadder) // You don't have to do '== true' cause the if statement already checks if it's true or false
{
disableDefMovement(); // Disables the defualt Movement system so we can control the player's movement
for ( temp.k = 0; temp.k < 4; temp.k += 2) // Cycles though the up and down arrow keycodes ( 0 - up, 2 - Down)
{
if ( keydown( temp.k)) //If player pushes an arrow key this will catch it
{
setani( this.ladderWalk, NULL): // Sets the players gani to the walking/moving ladder gani
player.y += vecy( temp.k) * 0.35; // Moves the players Y coor only, 0.35 is the speed, normal speed is 0.5 or 8 pixels every 0.05 seconds
// Vecy will return -1, 0, or 1. If temp.k is 0 then it will give -1, if temp.k is 1 or 3 it will give 0, If it's 2 then it will return 1
}
}
}
else // This will be called when player.onLadder is false
enableDefMovement(); // Enables the default movement system, so the player can move normally again
setTimer( 0.05); // Will call onTimeout in 0.05 seconds
}
|
__________________
Time is the fire in which we burn...
Up, Up, Down, Down, Left, Right, Left, Right, B, A, Select, Start! Now I got 99 LIVES!!!
|
Last edited by MrOmega; 11-14-2010 at 12:51 AM..
|
|
|