Advertisement
Guest User

Untitled

a guest
Jun 26th, 2016
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.86 KB | None | 0 0
  1. if (invincibility == 0) {
  2. if (collision_rectangle(x,y,x+32,y+32, obj_enemy, false, false)) {
  3. hp--
  4. invincibility = 30
  5. alarm[0] = 3
  6. }
  7. }
  8. if (hp == 0) {
  9. global.alive = false;
  10. instance_destroy()
  11. }
  12.  
  13. tmpx = x+hsp
  14. tmpy = y+vsp
  15.  
  16. //Get the player's inputs
  17. key_right = keyboard_check(vk_right) or keyboard_check(ord('D'))
  18. key_left = keyboard_check(vk_left) or keyboard_check(ord('A'))
  19. key_jump = keyboard_check_pressed(vk_up) or keyboard_check_pressed(ord('W'))
  20.  
  21. hsp = (-key_left + key_right) * movespd;
  22. if (vsp < 10) {
  23. vsp += grav;
  24. }
  25.  
  26. //vertical collision
  27. while (place_meeting(tmpx,tmpy,obj_wall)) {
  28. tmpy+=1
  29. }
  30. if (place_meeting(tmpx,tmpy+1,obj_wall)) {
  31. vsp = key_jump * -jumpspd
  32. }
  33.  
  34. //horizontal collision
  35. while (place_meeting(tmpx+hsp, tmpy, obj_wall)) {
  36. tempx+=sign(hsp)
  37. }
  38.  
  39. x = tmpx
  40. y = tmpy
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement