Advertisement
Purianite

Untitled

Mar 21st, 2012
390
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //Code snippet for player movement/per-frame operations from Kizuna: The Girl Who Saved Christmas
  2.  
  3. if dead = 1
  4. {
  5.     with (obj_playerbullet) instance_destroy();
  6.     if sound_isplaying(snd_shot) sound_stop(snd_shot);
  7. }
  8. if dead = 1 && xrot != -90 { xrot -= 3; }
  9. if dead = 0 && xrot < 0 { xrot += 6; }
  10. direction -= ((display_mouse_get_x() - display_get_width()/2) / 10) //for the mouse left/right movement
  11. //speed = 0 //so the player doesn't pick up massive speed every step
  12. if dead = 1 movespeed = 0;
  13. else movespeed = 4;
  14. // move forward
  15. if keyboard_check(ord("W"))
  16. {
  17.     nx = x + lengthdir_x(movespeed,direction);
  18.     ny = y + lengthdir_y(movespeed,direction);
  19.     if !place_meeting(nx, y, obj_wall_basic)  //check if object in path
  20.         x = nx;
  21.     if !place_meeting(x, ny, obj_wall_basic)  //check if object in path
  22.         y = ny;
  23. }
  24.  
  25. //move backwards
  26. if keyboard_check(ord("S"))
  27. {
  28.     nx = x + lengthdir_x(movespeed,direction+180);
  29.     ny = y + lengthdir_y(movespeed,direction+180);
  30.     if !place_meeting(nx, y, obj_wall_basic)  //check if object in path
  31.         x = nx;
  32.     if !place_meeting(x, ny, obj_wall_basic)  //check if object in path
  33.         y = ny;
  34. }
  35.  
  36. //strafe left
  37. if keyboard_check(ord("A"))
  38. {
  39.     nx = x - sin(direction*pi/180)*movespeed;
  40.     ny = y - cos(direction*pi/180)*movespeed;
  41.     if !place_meeting(nx, y, obj_wall_basic)  //check if object in path
  42.         x = nx;
  43.     if !place_meeting(x, ny, obj_wall_basic)  //check if object in path
  44.         y = ny;
  45. }
  46.  
  47. //strafe right
  48. if keyboard_check(ord("D"))
  49. {
  50.     nx = x + sin(direction*pi/180)*movespeed;
  51.     ny = y + cos(direction*pi/180)*movespeed;
  52.     if !place_meeting(nx, y, obj_wall_basic)  //check if object in path
  53.         x = nx;
  54.     if !place_meeting(x, ny, obj_wall_basic)  //check if object in path
  55.         y = ny;
  56. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement