Advertisement
Guest User

Untitled

a guest
Jul 5th, 2015
234
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.35 KB | None | 0 0
  1. if(strcmp(array[i-1][j-1].code, "LP") == 0){
  2. int oldDirection = direction;
  3. if(array[i-1][j-1].direction == ((direction)%4)){
  4. direction = ((direction) % 8); // keep direction
  5. }
  6. else if(array[i-1][j-1].direction == ((direction+1)%4)){
  7. direction = ((direction + 6) % 8);
  8. switch(direction){
  9. case 0:
  10. if(checkMove(i, j, direction, moves) == 0){
  11. return 0;
  12. }
  13. fillLaserPath(i, j-1, width, height, color, direction, array, colorArray, 0, moves);
  14. saveMove(i, j, direction, moves);
  15. break;
  16. case 1:
  17. if(checkMove(i, j, direction, moves) == 0){
  18. return 0;
  19. }
  20. fillLaserPath(i+1, j-1, width, height, color, direction, array, colorArray, 0, moves);
  21. saveMove(i, j, direction, moves);
  22. break;
  23. case 2:
  24. if(checkMove(i, j, direction, moves) == 0){
  25. return 0;
  26. }
  27. fillLaserPath(i+1, j, width, height, color, direction, array, colorArray, 0, moves);
  28. saveMove(i, j, direction, moves);
  29. break;
  30. case 3:
  31. if(checkMove(i, j, direction, moves) == 0){
  32. return 0;
  33. }
  34. fillLaserPath(i+1, j+1, width, height, color, direction, array, colorArray, 0, moves);
  35. saveMove(i, j, direction, moves);
  36. break;
  37. case 4:
  38. if(checkMove(i, j, direction, moves) == 0){
  39. return 0;
  40. }
  41. fillLaserPath(i, j+1, width, height, color, direction, array, colorArray, 0, moves);
  42. saveMove(i, j, direction, moves);
  43. break;
  44. case 5:
  45. if(checkMove(i, j, direction, moves) == 0){
  46. return 0;
  47. }
  48. fillLaserPath(i-1, j+1, width, height, color, direction, array, colorArray, 0, moves);
  49. saveMove(i, j, direction, moves);
  50. break;
  51. case 6:
  52. if(checkMove(i, j, direction, moves) == 0){
  53. return 0;
  54. }
  55. //fillLaserPath(i-1, j, width, height, color, direction, array, colorArray, 0, moves);
  56. saveMove(i, j, direction, moves);
  57. break;
  58. case 7:
  59. if(checkMove(i, j, direction, moves) == 0){
  60. return 0;
  61. }
  62. fillLaserPath(i-1, j-1, width, height, color, direction, array, colorArray, 0, moves);
  63. saveMove(i, j, direction, moves);
  64. break;
  65. }
  66. direction = oldDirection;
  67. }
  68. else if(array[i-1][j-1].direction == ((direction+3)%4)){
  69. direction = ((direction + 2) % 8);
  70. switch(direction){
  71. case 0:
  72. if(checkMove(i, j, direction, moves) == 0){
  73. return 0;
  74. }
  75. fillLaserPath(i, j-1, width, height, color, direction, array, colorArray, 0, moves);
  76. saveMove(i, j, direction, moves);
  77. break;
  78. case 1:
  79. if(checkMove(i, j, direction, moves) == 0){
  80. return 0;
  81. }
  82. fillLaserPath(i+1, j-1, width, height, color, direction, array, colorArray, 0, moves);
  83. saveMove(i, j, direction, moves);
  84. break;
  85. case 2:
  86. if(checkMove(i, j, direction, moves) == 0){
  87. return 0;
  88. }
  89. fillLaserPath(i+1, j, width, height, color, direction, array, colorArray, 0, moves);
  90. saveMove(i, j, direction, moves);
  91. break;
  92. case 3:
  93. if(checkMove(i, j, direction, moves) == 0){
  94. return 0;
  95. }
  96. fillLaserPath(i+1, j+1, width, height, color, direction, array, colorArray, 0, moves);
  97. saveMove(i, j, direction, moves);
  98. break;
  99. case 4:
  100. if(checkMove(i, j, direction, moves) == 0){
  101. return 0;
  102. }
  103. fillLaserPath(i, j+1, width, height, color, direction, array, colorArray, 0, moves);
  104. saveMove(i, j, direction, moves);
  105. break;
  106. case 5:
  107. if(checkMove(i, j, direction, moves) == 0){
  108. return 0;
  109. }
  110. fillLaserPath(i-1, j+1, width, height, color, direction, array, colorArray, 0, moves);
  111. saveMove(i, j, direction, moves);
  112. break;
  113. case 6:
  114. if(checkMove(i, j, direction, moves) == 0){
  115. return 0;
  116. }
  117. fillLaserPath(i-1, j, width, height, color, direction, array, colorArray, 0, moves);
  118. saveMove(i, j, direction, moves);
  119. break;
  120. case 7:
  121. if(checkMove(i, j, direction, moves) == 0){
  122. return 0;
  123. }
  124. fillLaserPath(i-1, j-1, width, height, color, direction, array, colorArray, 0, moves);
  125. saveMove(i, j, direction, moves);
  126. break;
  127. }
  128. direction = oldDirection;
  129. }
  130. else {
  131. return 0;
  132. }
  133. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement