SHARE
TWEET

1I1T - Movimento (Plataforma)

Alex_FC May 17th, 2019 51 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /* Movimento lateral */
  2. if keyboard_check(vk_left) hspeed = -5.3;
  3. else if keyboard_check(vk_right) hspeed = 5.3;
  4. else hspeed = 0;
  5.  
  6. /* Pulo */
  7. if keyboard_check_pressed(vk_up) and !place_free(x, y + 1) vspeed = -18.6;
  8.  
  9. vspeed += 0.7;              // Gravidade
  10. vspeed = min(vspeed, 15);   // Limita velocidade de queda
  11.  
  12. // Evita colisão horizontal, vertical e diagonal
  13. while !place_free(x + hspeed, y) hspeed -= min(abs(hspeed), 1) * sign(hspeed);
  14. while !place_free(x, y + vspeed) vspeed -= min(abs(vspeed), 1) * sign(vspeed);
  15. while !place_free(x + hspeed, y + vspeed)
  16. {
  17.     hspeed -= min(abs(hspeed), 1) * sign(hspeed);
  18.     vspeed -= min(abs(vspeed), 1) * sign(vspeed);
  19. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top