#include #include #include #include #define length 39 #define height 25 #define LEFT 75 #define RIGHT 77 #define ATTACT 32 #define MAXBUBBLE 3 int i = 0, j = 0; int px = 2, py = 23; int LorR; int m1x = 1, m1y = 16, m2x = 2, m2y = 11, m3x = 3, m3y = 6; int m4x = 68, m4y = 16, m5x = 70, m5y = 11, m6x = 69, m6y = 6; int m7x = 18, m7y = 16, m8x = 15, m8y = 11, m9x = 20, m9y = 6; int m10x = 49, m10y = 16, m11x = 49, m11y = 11, m12x = 49, m12y = 6; BOOL LR = 1, LR1 = 0, LR2 = 0, LR3 = 0, LR4 = 1, LR5 = 1, LR6 = 1, LR7 = 1, LR8 = 0, LR9 = 1, LR10 = 1, LR11 = 0, LR12 = 0; struct { BOOL exist; int x, y; }Bubble[MAXBUBBLE]; void gotoxy(int a, int b) { COORD pos = { a + 1,b + 1 }; SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE), pos); } void Draw_monster(int x, int y) { gotoxy(x, y); printf("¿ì"); } void Erase_monster(int x, int y) { gotoxy(x, y); printf(" "); } void Draw_player() { gotoxy(px, py); printf("¿Ê"); } void Erase_player() { gotoxy(px, py); printf(" "); } void Draw_bubble(int i) { gotoxy(Bubble[i].x, Bubble[i].y); printf("o"); } void Erase_bubble(int i) { gotoxy(Bubble[i].x, Bubble[i].y); printf(" "); } int map[height][length] = { 1,1,1,1,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,1,1,1,1, 1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1, 1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1, 1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1, 1,0,0,0,0,0,0,0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0,0,1,1,1,1,1,1,1,1,1,0,0,0,0,0,1,1,1,1,1,1,1,1,1,0,0,0,0,1,1,1,1, 1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1, 1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1, 1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1, 1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1, 1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1, 1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1, 1,1,1,1,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,1,1,1,1, }; void showmap() { int i, j; gotoxy(0, 0); for (i = 0; i < height; i++) { for (j = 0; j < length; j++) { switch (map[i][j]) { case 0: printf(" "); break; case 1: printf("¡á"); break; } } printf("\n"); } } void Player_move() { int c = 0; if (_kbhit()) { c = _getch(); if (c == 224) { c = _getch(); if (c == LEFT&&px > 1) { Erase_player(); px--; Draw_player(); if (Bubble[i].exist == FALSE) LorR = 0; } if (c == RIGHT&&px < 35) { Erase_player(); px++; Draw_player(); if (Bubble[i].exist == FALSE) LorR = 1; } } switch (c) { case ATTACT: for (i = 0; i < MAXBUBBLE&&Bubble[i].exist == TRUE; i++) { ; } if (i != MAXBUBBLE) { Bubble[i].x = px + 2; Bubble[i].y = py; Bubble[i].exist = TRUE; } break; } } } void attact() { int i = 0; for (i = 0; i < MAXBUBBLE; i++) { if (Bubble[i].exist == TRUE) { Erase_bubble(i); if (j>12) { Erase_bubble(i); Bubble[i].exist = FALSE; j = 0; } else { if (LorR == 0) { Bubble[i].x--; Draw_bubble(i); Sleep(30); j++; } else { Bubble[i].x++; Draw_bubble(i); Sleep(30); j++; } } } } } void Monster_move(int mx,int my) { Erase_monster(mx, my); if (mx==1||mx==4|| mx == 68 || mx == 72|| mx == 43 || mx == 59) { if (LR == 0) LR = 1; else LR = 0; if (LR == 0) { mx--; Draw_monster(mx, my); Sleep(10); } else { mx++; Draw_monster(mx, my); Sleep(10); } } else { if (LR == 0) { mx--; Draw_monster(mx, my); Sleep(10); } else { mx++; Draw_monster(mx, my); Sleep(10); } } if(mx==Bubble[i].x&&my==Bubble[i].x) { Erase_monster(mx, my); Erase_bubble(i); } } int main() { Draw_player(); showmap(); // ¸ÊÀ» ±×¸®´Â ÇÔ¼ö while (1) { Player_move(); Monster_move(m1x,m1y); Monster_move(m2x,m2y); Monster_move(m3x, m3y); Monster_move(m4x, m4y); Monster_move(m5x, m5y); Monster_move(m6x, m6y); Monster_move(m7x, m7y); Monster_move(m8x, m8y); Monster_move(m9x, m9y); Monster_move(m10x, m10y); Monster_move(m11x, m11y); Monster_move(m12x, m12y); attact(); } }