Guest User

Platform Code

a guest
Sep 7th, 2015
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. if (instance_exists(obj_player))
  2. {
  3.  
  4.  
  5.         obj_player.onMovingPlatform = false;
  6.  
  7.         var vPlayer = instance_place(x, y-obj_player.vsp, obj_player); // get an instance of the player that's colliding with this platform
  8.        
  9.         if (obj_player.vsp >= 0)
  10.         if (place_meeting(x, y-obj_player.vsp, obj_player)) { // check to make sure the player actually collided with this platform
  11.        
  12.             var playerBoundsOffset = sprite_get_bbox_bottom(obj_player.mask_index) - sprite_get_yoffset(obj_player.mask_index); // get the y position of the bottom of the player
  13.                      
  14.             if (obj_player.y + playerBoundsOffset - obj_player.vsp <= y + abs(vsp))  { // check to see if the bottom of the player is going to touch the top of this moving platform
  15.                 // the player touched the platform, so consider this as a touch on the ground, set their vertical velocity to zero, and reset their doublejump
  16.                 obj_player.grounded = 1;
  17.                 obj_player.vsp = 0;
  18.                 obj_player.djump =  obj_player.doubleJumpMaximum;
  19.                 obj_player.djump += 1;
  20.                 obj_player.pitch_jump = 0;
  21.                 obj_player.hsp_carry = hsp;
  22.                              
  23.                 var platformOffset = vsp;
  24.  
  25.                 obj_player.y = y - playerBoundsOffset + platformOffset; // move the player along with the platform
  26.                 obj_player.onMovingPlatform = true;
  27.             }    
  28.         }
  29. }
Advertisement
Add Comment
Please, Sign In to add comment