Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int moveIsPossible(int Row, int Col, int Destx, int Desty)
- {
- int i, canMove = 0;
- int dx,dy,dir;
- dx=Destx-Row;
- dy=Desty-Col;
- if (Row%2==0)
- {
- if (dx== -1&& dy== 0 ) {dir = 1;}
- if (dx== 1&& dy== 0) {dir = 2;}
- if (dx== 0&& dy== -1) {dir = 3;}
- if (dx== 0&& dy== 1) {dir = 4;}
- if (dx== 1&& dy== -1) {dir = 5;}
- if (dx== 1&& dy== 1) {dir = 6;}
- }
- else
- {
- if (dx== -1&& dy== 0 ) {dir = 1;}
- if (dx== 1&& dy== 0) {dir = 2;}
- if (dx== -1&& dy== -1) {dir = 3;}
- if (dx== -1&& dy== 1) {dir = 4;}
- if (dx== 0&& dy== -1) {dir = 5;}
- if (dx== 0&& dy== 1) {dir = 6;}
- }
- for(i = 0; i < 20; i++) {
- if(Row % 2 == 1) {
- switch(dir) { //Default the switch to what?
- case 1:
- Row--;
- break;
- case 2:
- Row++;
- break;
- case 3:
- Row--;
- Col--;
- break;
- case 4:
- Row--;
- Col++;
- break;
- case 5:
- Col--;
- break;
- case 6:
- Col++;
- break;
- }
- if (Destx==Row && Desty==Col)
- return 1;
- if(brdTab[Col][Row]>=1 && brdTab[Col][Row]<=3)
- canMove = 1;
- else
- return 0;
- } else {
- switch(dir) {
- case 1:
- Row--;
- break;
- case 2:
- Row++;
- break;
- case 3:
- Col--;
- break;
- case 4:
- Col++;
- break;
- case 5:
- Row++;
- Col--;
- break;
- case 6:
- Row++;
- Col++;
- break;
- }
- if (Destx==Row && Desty==Col)
- return 1;
- if(brdTab[Col][Row]>=1 && brdTab[Col][Row]<=3)
- canMove = 1;
- else
- return 0;
- }
- }
- if (Destx==Row && Desty==Col)
- return 1;
- else
- return 0;
- return canMove;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement