Advertisement
Guest User

sadfasdfasdf

a guest
Dec 8th, 2016
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.92 KB | None | 0 0
  1. void moveObject1()
  2. {
  3.  
  4.  
  5. if(directionXObstacle1 != 0 && directionYObstacle1 !=0)
  6. { //If it is diagonal
  7.  
  8.  
  9.  
  10.  
  11. }
  12. else
  13. {//if not diagonal
  14.  
  15. if(directionXObstacle1 == 2 && directionYObstacle1 == 0)
  16. {
  17. //south
  18.  
  19. //check to see if it will hit wall
  20. if(startingPointXObstacle1 + speedObstacle1 > gridSize )
  21. {
  22. int holder = startingPointXObstacle1 + speedObstacle1 - gridSize;
  23.  
  24. startingPointXObstacle1 = gridSize - holder;
  25. directionXObstacle1 = 1;
  26. }
  27. else
  28. {
  29. startingPointXObstacle1 += speedObstacle1;
  30. }
  31.  
  32.  
  33. }
  34.  
  35. else if(directionXObstacle1 == 1 && directionYObstacle1 == 0)
  36. {
  37. //north
  38. //check to see if it will hit wall
  39. if(startingPointXObstacle1 - speedObstacle1 < 1 )
  40. {
  41. int holder = (startingPointXObstacle1 - speedObstacle1) -1;
  42. startingPointXObstacle1 = 1 + (holder * -1);
  43. startingPointXObstacle1 = 2;
  44. directionXObstacle1 = 2;
  45. }
  46. else
  47. {
  48. startingPointXObstacle1 -= speedObstacle1;
  49. }
  50.  
  51.  
  52. }
  53.  
  54. else if(directionXObstacle1 == 0 && directionYObstacle1 == 2)
  55. {
  56. //east
  57. //check to see if it will hit wall
  58. if(startingPointYObstacle1 + speedObstacle1 > gridSize )
  59. {
  60. int holder = startingPointYObstacle1 + speedObstacle1 - gridSize;
  61.  
  62. startingPointYObstacle1 = gridSize - holder;
  63. directionYObstacle1 = 1;
  64. }
  65. else
  66. {
  67. startingPointYObstacle1 += speedObstacle1;
  68.  
  69.  
  70. }
  71. }
  72. else if( directionXObstacle1 == 0 && directionYObstacle1 == 1)
  73. {
  74. //west
  75. if(startingPointYObstacle1 - speedObstacle1 < 1 )
  76. {
  77. int holder = (startingPointYObstacle1 - speedObstacle1) -1;
  78.  
  79. startingPointYObstacle1 = 1 + (holder * -1);
  80. directionYObstacle1 = 2;
  81.  
  82. }
  83. else
  84. {
  85. startingPointYObstacle1 -= speedObstacle1;
  86. }
  87. }
  88.  
  89. }
  90. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement