Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- if(strcmp(array[i-1][j-1].code, "LP") == 0){
- int oldDirection = direction;
- if(array[i-1][j-1].direction == ((direction)%4)){
- direction = ((direction) % 8); // keep direction
- }
- else if(array[i-1][j-1].direction == ((direction+1)%4)){
- direction = ((direction + 6) % 8);
- switch(direction){
- case 0:
- if(checkMove(i, j, direction, moves) == 0){
- return 0;
- }
- fillLaserPath(i, j-1, width, height, color, direction, array, colorArray, 0, moves);
- saveMove(i, j, direction, moves);
- break;
- case 1:
- if(checkMove(i, j, direction, moves) == 0){
- return 0;
- }
- fillLaserPath(i+1, j-1, width, height, color, direction, array, colorArray, 0, moves);
- saveMove(i, j, direction, moves);
- break;
- case 2:
- if(checkMove(i, j, direction, moves) == 0){
- return 0;
- }
- fillLaserPath(i+1, j, width, height, color, direction, array, colorArray, 0, moves);
- saveMove(i, j, direction, moves);
- break;
- case 3:
- if(checkMove(i, j, direction, moves) == 0){
- return 0;
- }
- fillLaserPath(i+1, j+1, width, height, color, direction, array, colorArray, 0, moves);
- saveMove(i, j, direction, moves);
- break;
- case 4:
- if(checkMove(i, j, direction, moves) == 0){
- return 0;
- }
- fillLaserPath(i, j+1, width, height, color, direction, array, colorArray, 0, moves);
- saveMove(i, j, direction, moves);
- break;
- case 5:
- if(checkMove(i, j, direction, moves) == 0){
- return 0;
- }
- fillLaserPath(i-1, j+1, width, height, color, direction, array, colorArray, 0, moves);
- saveMove(i, j, direction, moves);
- break;
- case 6:
- if(checkMove(i, j, direction, moves) == 0){
- return 0;
- }
- //fillLaserPath(i-1, j, width, height, color, direction, array, colorArray, 0, moves);
- saveMove(i, j, direction, moves);
- break;
- case 7:
- if(checkMove(i, j, direction, moves) == 0){
- return 0;
- }
- fillLaserPath(i-1, j-1, width, height, color, direction, array, colorArray, 0, moves);
- saveMove(i, j, direction, moves);
- break;
- }
- direction = oldDirection;
- }
- else if(array[i-1][j-1].direction == ((direction+3)%4)){
- direction = ((direction + 2) % 8);
- switch(direction){
- case 0:
- if(checkMove(i, j, direction, moves) == 0){
- return 0;
- }
- fillLaserPath(i, j-1, width, height, color, direction, array, colorArray, 0, moves);
- saveMove(i, j, direction, moves);
- break;
- case 1:
- if(checkMove(i, j, direction, moves) == 0){
- return 0;
- }
- fillLaserPath(i+1, j-1, width, height, color, direction, array, colorArray, 0, moves);
- saveMove(i, j, direction, moves);
- break;
- case 2:
- if(checkMove(i, j, direction, moves) == 0){
- return 0;
- }
- fillLaserPath(i+1, j, width, height, color, direction, array, colorArray, 0, moves);
- saveMove(i, j, direction, moves);
- break;
- case 3:
- if(checkMove(i, j, direction, moves) == 0){
- return 0;
- }
- fillLaserPath(i+1, j+1, width, height, color, direction, array, colorArray, 0, moves);
- saveMove(i, j, direction, moves);
- break;
- case 4:
- if(checkMove(i, j, direction, moves) == 0){
- return 0;
- }
- fillLaserPath(i, j+1, width, height, color, direction, array, colorArray, 0, moves);
- saveMove(i, j, direction, moves);
- break;
- case 5:
- if(checkMove(i, j, direction, moves) == 0){
- return 0;
- }
- fillLaserPath(i-1, j+1, width, height, color, direction, array, colorArray, 0, moves);
- saveMove(i, j, direction, moves);
- break;
- case 6:
- if(checkMove(i, j, direction, moves) == 0){
- return 0;
- }
- fillLaserPath(i-1, j, width, height, color, direction, array, colorArray, 0, moves);
- saveMove(i, j, direction, moves);
- break;
- case 7:
- if(checkMove(i, j, direction, moves) == 0){
- return 0;
- }
- fillLaserPath(i-1, j-1, width, height, color, direction, array, colorArray, 0, moves);
- saveMove(i, j, direction, moves);
- break;
- }
- direction = oldDirection;
- }
- else {
- return 0;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement