Thread: ladder script
View Single Post
  #2  
Old 11-14-2010, 12:25 AM
MrOmega MrOmega is offline
One More Time
MrOmega's Avatar
Join Date: Aug 2010
Location: TN, USA
Posts: 631
MrOmega is an unknown quantity at this point
Send a message via AIM to MrOmega Send a message via MSN to MrOmega Send a message via Yahoo to MrOmega
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

  
setImgthis.ladderImg); // Sets the ladder image
  
setshape1getimgwidththis.ladderImg), getimgheightthis.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.1.5 in this.xthis.+ (  getimgwidththis.ladderImg) / 16)| &&
       
player.2.0 in this.ythis.+ ( getimgheightthis.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
    
setanithis.ladderIdleNULL); // 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.0temp.4temp.+= 2)  // Cycles though the up and down arrow keycodes ( 0 - up, 2 - Down)
    
{

      if ( 
keydowntemp.k)) //If player pushes an arrow key this will catch it
      
{

        
setanithis.ladderWalkNULL): // Sets the players gani to the walking/moving ladder gani 
        
player.+= vecytemp.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

  
setTimer0.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..
Reply With Quote