#include #include #include #include #include #include #include #include #include #define MAZE_SIZE 19 #define UP KEY_UP #define DOWN KEY_DOWN #define RIGHT KEY_RIGHT #define LEFT KEY_LEFT int maze[MAZE_SIZE][MAZE_SIZE] = { { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 }, { 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1 }, { 1, 0, 1, 0, 1, 1, 1, 0, 1, 1, 1, 1, 1, 0, 1, 0, 1, 0, 1 }, { 1, 0, 1, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 1, 0, 1 }, { 1, 0, 1, 0, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 0, 1, 0, 1 }, { 1, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1 }, { 1, 0, 1, 1, 1, 0, 1, 0, 1, 1, 1, 0, 1, 0, 1, 0, 1, 0, 1 }, { 1, 0, 0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1 }, { 1, 1, 1, 1, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1 }, { 1, 0, 0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1 }, { 1, 0, 1, 1, 1, 1, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1 }, { 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, 1, 1, 0, 1 }, { 1, 0, 1, 1, 1, 1, 1, 0, 1, 0, 1, 1, 1, 0, 1, 0, 1, 0, 1 }, { 1, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, 0, 1, 0, 1 }, { 1, 0, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 0, 1, 0, 1 }, { 1, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1 }, { 1, 0, 1, 0, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1 }, { 1, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 } }; typedef struct{ int x; int y; }pos; int main() { int i=0; int j=0; int key; pos now; now.x=17; now.y=36; setlocale(LC_ALL, "ko_KR.utf8"); initscr(); keypad(stdscr, TRUE); for (j = 0; j < MAZE_SIZE; j++){ move(j,0); for (i = 0; i < MAZE_SIZE; i++) { if(maze[j][i]){ printw("ㅁ"); } else{ printw(" "); } } } move(now.x,now.y); printw("*"); refresh(); while(key = getch()){ switch(key){ case UP: move(now.x,now.y); printw(" "); now.x--; if(maze[now.x][(now.y/2)]) now.x++; break; case DOWN: move(now.x,now.y); printw(" "); now.x++; if(maze[now.x][(now.y/2)]) now.x--; break; case RIGHT: move(now.x,now.y); printw(" "); now.y+=2; if(maze[now.x][(now.y/2)]) now.y-=2; break; case LEFT: move(now.x,now.y); printw(" "); now.y-=2; if(maze[now.x][(now.y/2)]) now.y+=2; break; } move(now.x,now.y); printw("*"); move(23,79); refresh(); if(now.x == 1 && now.y==0){ move(4,50); printw("The End!!!!"); move(23,79); refresh(); break; } } getch(); endwin(); return 0; }