#include #include #include #include char PrintMap_easy[15][15] = { 0 }; int G1=0, G2 = 0; int B1 = 0, B2 = 0; int P1 = 0, P2 = 0; //GÀÇ ¿ø·¡À§Ä¡ °áÇÔ¹æÁö int GP1 = 0, GP2 = 0; int GP = 0; // ³­À̵µº° ¸Ê int Map_easy(void) { char Map_easy[15][15] = { 0 }; // int i = 0, j = 0; for (i = 0; i < 15; ++i) { for (j = 0; j < 15; ++j) { Map_easy[i][j] = 'W'; } } for (i = 1; i < 9; ++i) { for (j = 1; j < 9; ++j) { Map_easy[i][j] = '.'; } } //Ç÷¹À̾î,°ñÀÎÁ¡,¹Ú½º À§Ä¡¸¦ ÁÂÇ¥·Î ±â¼ú Map_easy[8][5] = 'P'; P1 = 8, P2 = 5; Map_easy[1][7] = 'G'; G1 = 1, G2 = 7; Map_easy[6][7] = 'B'; B1 = 6, B2 = 7; strcpy(PrintMap_easy, Map_easy); return 0; } int Map_normal(void) { char Map_normal[15][15] = { 0 }; // int i = 0, j = 0; for (i = 0; i < 15; ++i) { for (j = 0; j < 15; ++j) { Map_normal[i][j] = 'W'; } } for (i = 1; i < 12; ++i) { for (j = 1; j < 12; ++j) { Map_normal[i][j] = '.'; } } //Ç÷¹À̾î,°ñÀÎÁ¡,¹Ú½º À§Ä¡¸¦ ÁÂÇ¥·Î ±â¼ú Map_normal[8][5] = 'P'; P1 = 8, P2 = 5; Map_normal[1][7] = 'G'; G1 = 1, G2 = 7; Map_normal[6][7] = 'B'; B1 = 6, B2 = 7; strcpy(PrintMap_easy, Map_normal); return 0; } int Map_hard(void) { char Map_hard[15][15] = { 0 }; // int i = 0, j = 0; for (i = 0; i < 15; ++i) { for (j = 0; j < 15; ++j) { Map_hard[i][j] = 'W'; } } for (i = 1; i < 14; ++i) { for (j = 1; j < 14; ++j) { Map_hard[i][j] = '.'; } } //Ç÷¹À̾î,°ñÀÎÁ¡,¹Ú½º À§Ä¡¸¦ ÁÂÇ¥·Î ±â¼ú Map_hard[8][5] = 'P'; P1 = 8, P2 = 5; Map_hard[1][7] = 'G'; G1 = 1, G2 = 7; Map_hard[6][7] = 'B'; B1 = 6, B2 = 7; strcpy(PrintMap_easy, Map_hard); return 0; } //ÅؽºÆ® »ö±ò¹Ù²Ù±â void textcolor(int color_number) { SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), color_number); } //½ÃÀÛÈ­¸é int FirstScreen(void) { int nInput = 0; printf("Move Box Á¦ÀÛÀÚ:½É¸íÁø \n"); printf("³­À̵µ¸¦ ¼±ÅÃÇϽÿÀ.\n1.easy\n2.normal\n3.hard\n"); while (nInput != 1 && nInput != 2 && nInput != 3) { scanf_s("%d",&nInput,sizeof(nInput)); } system("cls"); return nInput; } //°ÔÀÓ¿£Áø int GamePlay(int i2, int j2,char Map[15][15]) { int clear = 0; int i = 0, j = 0; int OP1 = P1, OP2 = P2, OG1 = G1, OG2 = G2, OB1 = B1, OB2 = B2; char Input=0; if (OP1 == P1) { system("cls"); printf("wasd:À̵¿\n"); for (i = 0; i < i2; ++i) { for (j = 0; j < j2; ++j) { printf("%c\t", Map[i][j]); } putchar('\n'); putchar('\n'); } } Input = getch(); if (Input == 'w' || Input == 'a' || Input == 's' || Input == 'd') { if (Input == 'w') { P1 -= 1; } else if (Input == 'a') { P2 -= 1; } else if (Input == 's') { P1 += 1; } else if (Input == 'd') { P2 += 1; } if (Map[P1][P2] == '.') { Map[OP1][OP2] = '.'; Map[P1][P2] = 'P'; } else if (Map[P1][P2] == 'W') { P1 = OP1; P2 = OP2; } // °áÇÔ else if (Map[P1][P2] == 'G') { GP = 1; GP1 = OG1; GP2 = OG2; Map[OP1][OP2] = '.'; Map[P1][P2] = 'P'; } else if (Map[P1][P2] == 'B') { if (Input == 'w') { B1 -= 1; } else if (Input == 'a') { B2 -= 1; } else if (Input == 's') { B1 += 1; } else if (Input == 'd') { B2 += 1; } { if (Map[B1][B2] == '.') { Map[B1][B2] = 'B'; Map[OB1][OB2] = 'P'; Map[OP1][OP2] = '.'; } else if (Map[B1][B2] == 'W') { P1 = OP1; P2 = OP2; B1 = OB1; B2 = OB2; } else if (Map[B1][B2] == 'G') { clear = 1; Map[B1][B2] = 'B'; Map[OB1][OB2] = 'P'; Map[OP1][OP2] = '.'; } } } } if (Map[OG1][OG2] == '.') { Map[OG1][OG2] = 'G'; } system("cls"); printf("wasd:À̵¿\n"); for (i = 0; i < i2; ++i) { for (j = 0; j < j2; ++j) { printf("%c\t", Map[i][j]); } putchar('\n'); putchar('\n'); } putchar('\a'); return clear; } int main(void) { int clear = 0; int nInput = 0; int i = 0, j = 0; int i2 = 15, j2 = 15; char *Index1[15][15] = { NULL }; //ÄܼÖâ Å©±âÁ¶Àý °¡·Î2=¼¼·Î1 system("mode con cols=200 lines=80"); //½ÃÀÛÈ­¸é¿¡¼­ ³­À̵µ¸¦ ÀԷ¹ޱâ nInput=FirstScreen(); if (nInput == 1) { Map_easy(); strcpy(Index1, PrintMap_easy); while (clear == 0) { clear=GamePlay(i2,j2,Index1); } } else if (nInput == 2) { Map_normal(); strcpy(Index1, PrintMap_easy); while (clear == 0) { clear = GamePlay(i2, j2, Index1); } } else if (nInput == 3) { Map_hard(); strcpy(Index1, PrintMap_easy); while (clear == 0) { clear = GamePlay(i2, j2, Index1); } } printf("game clear\n"); _getch(); return 0; } //