#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; BOOL LR = 1; struct { int no; int mx; int old_mx; int my; int m_vel; char name[10]; int action; }monster[12]; struct { BOOL exist; int x, y; int b_vel; }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,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,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,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, j = 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) { if (Bubble[i].b_vel % 10 == 0) { Bubble[i].x--; Draw_bubble(i); } j++; Bubble[i].b_vel++; } else { if (Bubble[i].b_vel % 10 == 0) { Bubble[i].x++; Draw_bubble(i); } j++; Bubble[i].b_vel++; } } } } } void Monster_move(int i) { if (monster[i].m_vel % 1000 == 0) { Erase_monster(monster[i].mx, monster[i].my); if (monster[i].mx == 1 || monster[i].mx == 4 || monster[i].mx == 68 || monster[i].mx == 72 || monster[i].mx == 43 || monster[i].mx == 59 || monster[i].mx == 15 || monster[i].mx == 30) { if (monster[i].old_mx < monster[i].mx) { monster[i].old_mx = monster[i].mx; monster[i].mx--; Draw_monster(monster[i].mx, monster[i].my); } else { monster[i].old_mx = monster[i].mx; monster[i].mx++; Draw_monster(monster[i].mx, monster[i].my); } } else { if (monster[i].old_mx > monster[i].mx) { monster[i].old_mx = monster[i].mx; monster[i].mx--; Draw_monster(monster[i].mx, monster[i].my); } else { monster[i].old_mx = monster[i].mx; monster[i].mx++; Draw_monster(monster[i].mx, monster[i].my); } } } if (monster[i].mx == Bubble[i].x&&monster[i].my == Bubble[i].x) { Erase_monster(monster[i].mx, monster[i].my); Erase_bubble(i); } monster[i].m_vel++; } int main() { monster[0].mx = 2; monster[0].my = 16; monster[1].mx = 1; monster[1].my = 11; monster[2].mx = 3; monster[2].my = 6; monster[3].mx = 69; monster[3].my = 16; monster[4].mx = 70; monster[4].my = 11; monster[5].mx = 68; monster[5].my = 6; monster[6].mx = 15; monster[6].my = 16; monster[7].mx = 20; monster[7].my = 11; monster[8].mx = 25; monster[8].my = 6; monster[9].mx = 47; monster[9].my = 16; monster[10].mx = 44; monster[10].my = 11; monster[11].mx = 50; monster[11].my = 6; monster[0].old_mx = monster[0].mx; monster[1].old_mx = monster[1].mx; monster[2].old_mx = monster[2].mx; monster[3].old_mx = monster[3].mx; monster[4].old_mx = monster[4].mx; monster[5].old_mx = monster[5].mx; monster[6].old_mx = monster[6].mx; monster[7].old_mx = monster[7].mx; monster[8].old_mx = monster[8].mx; monster[9].old_mx = monster[9].mx; monster[10].old_mx = monster[10].mx; monster[11].old_mx = monster[11].mx; Bubble[0].b_vel = 0; Bubble[1].b_vel = 0; Bubble[2].b_vel = 0; for (i = 0; i<12; i++) monster[i].m_vel = 0; Draw_player(); showmap(); // ¸ÊÀ» ±×¸®´Â ÇÔ¼ö while (1) { Player_move(); for (i = 0; i<12; i++) { Monster_move(i); } attact(); } }