어디가 문제인지..
어떤문제 인지는 질문자가 파악하고 해결책을 질문해야죠
볼란도 님이 쓰신 글 :
:
: #include <iostream>
: #include <windows.h>
: #include <conio.h>
: using namespace std;
:
: #define LEFT 75
: #define RIGHT 77
: #define UP 72
: #define DOWN 80
:
: void gotoxy(int x, int y);
: void setmap();
: bool move(char ch);
:
: char startx = 0;
: char starty = 0;
: char endx = 0;
: char endy = 0;
: int intro_cho,gamestart_cho,howto_cho;
:
: //1-13
:
: char map[25][25] = { {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},
: {1,2,1,0,1,1,0,1,0,0,0,1,0,0,0,0,1,1,0,0,1,0,0,0,1},
: {1,0,1,0,0,0,0,1,0,1,0,1,0,0,1,0,0,0,0,1,1,0,1,0,1},
: {1,0,1,0,1,1,0,1,0,0,0,1,1,0,1,1,0,1,0,1,0,0,1,0,1},
: {1,0,1,0,0,0,0,1,1,0,1,1,0,0,0,1,1,1,0,1,0,1,1,0,1},
: {1,0,1,1,1,1,0,0,0,0,0,1,0,1,0,0,0,1,0,0,0,1,1,0,1},
: {1,0,0,0,0,0,0,1,0,1,0,1,0,1,1,0,0,1,0,1,1,1,1,0,1},
: {1,0,1,1,0,1,0,1,0,1,0,1,0,0,1,0,0,1,0,1,0,0,1,0,1},
: {1,0,1,0,0,1,0,1,0,1,0,1,0,0,1,0,0,1,0,1,0,0,1,0,1},
: {1,0,1,0,1,0,0,1,0,1,0,1,0,0,1,0,0,1,0,0,0,0,1,0,1},
: {1,0,1,0,1,0,1,1,0,1,0,1,0,0,1,1,0,1,1,1,0,0,1,0,1},
: {1,0,1,0,0,0,1,0,0,1,0,0,0,0,0,1,0,1,0,1,0,0,1,0,1},
: {1,0,1,1,1,1,1,0,1,1,1,1,0,1,1,1,0,1,0,1,0,1,1,0,1},
: {1,0,0,0,0,0,1,0,0,0,0,1,0,1,0,0,0,0,0,1,0,1,0,0,1},
: {1,1,1,1,0,1,1,0,1,0,0,1,0,1,0,0,1,1,1,1,0,1,1,0,1},
: {1,0,0,1,0,0,0,0,1,0,0,1,0,1,1,0,0,1,0,0,1,0,0,0,1},
: {1,0,1,1,0,0,1,0,1,1,1,1,0,1,0,0,1,1,0,1,1,1,0,1,1},
: {1,0,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1,1,0,1,0,1,0,1,1},
: {1,0,1,1,0,1,1,1,1,1,0,1,0,0,1,1,1,0,0,1,0,1,0,1,1},
: {1,0,1,0,0,0,0,0,0,0,0,1,0,0,1,0,1,0,0,0,1,0,0,0,1},
: {1,0,1,0,1,1,1,0,1,0,1,1,0,1,1,1,0,0,0,1,0,1,0,1,1},
: {1,0,1,0,0,0,0,0,1,0,0,1,0,0,0,1,1,1,0,1,0,1,0,0,1},
: {1,0,1,1,1,1,1,1,1,1,0,1,1,1,0,1,0,0,0,1,0,1,1,0,1},
: {1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,3,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,1}};
:
: void intro(){
: cout<<endl;
: cout<<" ★◆★◆★◆★◆★◆★◆★◆★◆★◆★◆★◆★◆★◆★◆★◆★◆★◆★◆"<<endl;
: cout<<" ◆ ★"<<endl;
: cout<<" ★ ◆"<<endl;
: cout<<" ◆ ├─┬─┐ │ ├── ┌──┐ ├─┬─┐ │ ├── ┌──┐ ★"<<endl;
: cout<<" ★ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ◆"<<endl;
: cout<<" ◆ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ★"<<endl;
: cout<<" ★ │ │ │ │ │ └──┘ │ │ │ │ │ └──┘ ◆"<<endl;
: cout<<" ◆ ★"<<endl;
: cout<<" ★ ◆"<<endl;
: cout<<" ◆ ★"<<endl;
: cout<<" ★◆★◆★◆★◆★◆★◆★◆★◆★◆★◆★◆★◆★◆★◆★◆★◆★◆★◆"<<endl;
: cout<<endl;
: cout<<"\t\t\t\t1. 게임 시작"<<endl;
: cout<<"\t\t\t\t2. 게임 설명"<<endl;
: cout<<"\t\t\t\t3. 게임 종료"<<endl<<endl;
: cout<<"\t\t\t\t선택 : ";
: cin>>intro_cho;
: } //게임 첫번째 화면 //intro
:
: void howto(){
: cout<<endl;
: cout<<" ┌──────────────────────────────────┐"<<endl;
: cout<<" │ │"<<endl;
: cout<<" │ │"<<endl;
: cout<<" │ << 게 임 설 명 >> │"<<endl;
: cout<<" │ │"<<endl;
: cout<<" │ 주어진 미로 길에 따라서 출구를 찾아 나아가는 게임 │"<<endl;
: cout<<" │ 출구를 찾아나간다!!! │"<<endl;
: cout<<" │ │"<<endl;
: cout<<" │ │"<<endl;
: cout<<" │ << 사용조작 방법 >> │"<<endl;
: cout<<" │ │"<<endl;
: cout<<" │ ←, →, ↑, ↓ 방향키 │"<<endl;
: cout<<" │ │"<<endl;
: cout<<" │ │"<<endl;
: cout<<" │ │"<<endl;
: cout<<" └──────────────────────────────────┘"<<endl<<endl;
: cout<<"\t\t\t\t1. 뒤로 가기"<<endl;
: cout<<endl;
: cout<<"\t\t\t\t선택 : ";
: cin>>howto_cho;
: }//게임 방법 설명 창
:
: void exit(){
: cout<<endl<<endl<<endl<<endl<<endl;
: cout<<"\t\t\t << The End >>"<<endl;
: cout<<"\t\t\t MIRO MIRO"<<endl;
: cout<<endl<<endl<<endl<<endl<<endl<<endl;
: }//게임 종료 창
: /////////////////메인 부분...
: void main(){
: intro();
: while(1){
: if(intro_cho==1){
: system("cls");
: setmap();
: if(gamestart_cho==1){
: system("cls");
: intro();
: }
: }
: else if(intro_cho==2){
: system("cls");
: howto();
: if(howto_cho==1){
: system("cls");
: intro();
: }
: }
: else if(intro_cho==3){
: system("cls");
: exit();
: break;
: }
: }//while
: /*
: setmap();
: while(true) {
: if(move(getch())) {
: break;
: }
: }
: while(getch() != 27) {
: gotoxy(0,26);
: printf("clear\n종료는 esc\n");
: }
: */
:
: }//main
:
: /******************3번*********************/
: bool move(char ch) {
: switch(ch) {
: case LEFT:
: if(map[starty][startx-1] != 1) {
: cout<<" ";
: startx--;
: }
: break;
: case RIGHT:
: if(map[starty][startx+1] != 1){
: cout<<" ";
: startx++;
: }
: break;
: case UP:
: if(map[starty-1][startx] != 1){
: cout<<" ";
: starty--;
: }
: break;
: case DOWN:
: if(map[starty+1][startx] != 1){
: cout<<" ";
: starty++;
: }
: break;
: }
: gotoxy(startx*2,starty);
: cout<<"◎";
: gotoxy(startx*2,starty);
: if(map[startx][starty] == map[endx][endy])
: return true;
: else
: return false;
: }
:
: /******************4번**********************/
: void setmap() {
: char ch;
: for(int i=0; i<sizeof(map) / sizeof(map[0]); i++) {
: for(int j=0; j<sizeof(map[0]) / sizeof(map[0][0]); j++) {
: ch = map[i][j];
: switch(ch) { //4-3
: case 0:
: cout<<" ";
: break;
: case 1:
: cout<<"■";
: break;
: case 2:
: cout<<"◎";
: startx = i;
: starty = j;
: break;
: case 3 :
: cout<<"♥";
: endx = i;
: endy = j;
: break;
: }//switch
: }
: cout<<endl;
: }//for
: gotoxy(startx*2, starty); //4-4
: }//setmap
:
: /******************5번*********************///콘솔 좌표 이동
: void gotoxy(int x, int y) {
: COORD position = {x, y};
: SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE), position);
: }
: