Guest User

Untitled

a guest
Dec 5th, 2013
240
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //movement code
  2.  
  3. if canmove{           //variables used for other stuff
  4. if hascontrol{
  5. if (keyboard_check_direct(ord('W'))&&keyboard_check_direct(ord('A'))){
  6.     if place_meeting(x-3, y, obj_newWall)&&!place_meeting(x, y-3, obj_newWall){     //if about to collide with something horizontally BUT not vertically, go up
  7.         motion_set(90, 3);
  8.         }
  9.     else if !place_meeting(x-3, y, obj_newWall)&&place_meeting(x, y-3, obj_newWall){   //if about to collide with something vertically BUT not horizontally, move horizontally NOT WORKING AS INTENDED
  10.         motion_set(180, 3);
  11.         }
  12.     else if place_meeting(x-3, y, obj_newWall)&&place_meeting(x, y-3, obj_newWall)  // if about to collide both ways, just stop
  13.         motion_set(direction, 0)
  14.     else
  15.         motion_set(135, 3);                                                         // otherwise, move normally
  16.     }
  17. else if (keyboard_check_direct(ord('W'))&&keyboard_check_direct(ord('D'))){
  18.    
  19.     if place_meeting(x+3, y, obj_newWall)&&!place_meeting(x, y-3, obj_newWall){  
  20.         motion_set(90, 3);                                                                      //CONTINUE THE PATTERN
  21.         }
  22.     else if !place_meeting(x+3, y, obj_newWall)&&place_meeting(x, y-3, obj_newWall){
  23.         motion_set(0, 3);
  24.         }
  25.     else if place_meeting(x+3, y, obj_newWall)&&place_meeting(x, y-3, obj_newWall)
  26.         motion_set(direction, 0)
  27.     else motion_set(45, 3);
  28.     }
  29. else if (keyboard_check_direct(ord('S'))&&keyboard_check_direct(ord('D'))){
  30.    
  31.     if place_meeting(x+3, y, obj_newWall)&&!place_meeting(x, y+3, obj_newWall){  
  32.         motion_set(270, 3);
  33.         }
  34.     else if !place_meeting(x+3, y, obj_newWall)&&place_meeting(x, y+3, obj_newWall){
  35.         motion_set(0, 3);
  36.         }
  37.     else if place_meeting(x+3, y, obj_newWall)&&place_meeting(x,y+3, obj_newWall)
  38.         motion_set(direction, 0)
  39.     else motion_set(315, 3);
  40.     }
  41. else if (keyboard_check_direct(ord('S'))&&keyboard_check_direct(ord('A'))){
  42.    
  43.     if place_meeting(x-3, y, obj_newWall)&&!place_meeting(x, y+3, obj_newWall){  
  44.         motion_set(270, 3);
  45.         }
  46.     else if !place_meeting(x-3, y, obj_newWall)&&place_meeting(x, y+3, obj_newWall){
  47.         motion_set(180, 3);
  48.         }
  49.     else if place_meeting(x-3, y, obj_newWall)&&place_meeting(x, y+3, obj_newWall)
  50.         motion_set(direction, 0)
  51.     else motion_set(225, 3);
  52.     }
  53. else{
  54. if keyboard_check_direct(ord('W'))
  55. {
  56.     motion_set(90, 3);
  57.     if place_meeting(x, y-3, obj_newWall)       // set motion first, then check for immediate collision. if collision imminent, keep direction and speed = 0
  58.         motion_set(90, 0);                      // pattern continues below
  59. }
  60.  
  61.  
  62.  
  63. if keyboard_check_direct(ord('S'))
  64. {
  65.     motion_set(270, 3);
  66.     if place_meeting(x, y+3, obj_newWall)
  67.         motion_set(270, 0);
  68.        
  69. }
  70.  
  71.  
  72.  
  73. if keyboard_check_direct(ord('A'))
  74. {
  75.     motion_set(180, 3);
  76.     if place_meeting(x-3, y, obj_newWall)  
  77.         motion_set(180, 0);
  78.        
  79. }
  80.  
  81.  
  82.  
  83. if keyboard_check_direct(ord('D'))
  84. {
  85.     motion_set(0, 3);
  86.     if place_meeting(x+3, y, obj_newWall)  
  87.         motion_set(0,0);
  88.  
  89. }
  90.  
  91. }
  92.  
  93.  
  94. if keyboard_check_released(ord('W'))
  95. or keyboard_check_released(ord('S'))
  96. or keyboard_check_released(ord('D'))                                //Stop moving when keys are released, don't change direction.
  97. or keyboard_check_released(ord('A'))
  98. {
  99. speed = 0
  100. }
  101. }
  102. }
  103. else speed = 0;
Advertisement
Add Comment
Please, Sign In to add comment