Turbo-C
C++Builder  |  Delphi  |  FireMonkey  |  C/C++  |  Free Pascal  |  Firebird
볼랜드포럼 BorlandForum
 경고! 게시물 작성자의 사전 허락없는 메일주소 추출행위 절대 금지
터보-C 포럼
Q & A
FAQ
팁&트릭
강좌/문서
자료실
Lua 게시판
볼랜드포럼 홈
헤드라인 뉴스
IT 뉴스
공지사항
자유게시판
해피 브레이크
공동 프로젝트
구인/구직
회원 장터
건의사항
운영진 게시판
회원 메뉴
북마크
볼랜드포럼 광고 모집

C/C++ Q/A
[6910] Re:c++로 미로게임을 만들고 있는데, 어디가 문제인지..
Intotheblue [makerjh] 1714 읽음    2014-11-15 13:59
어디가 문제인지..
어떤문제 인지는 질문자가 파악하고 해결책을 질문해야죠

볼란도 님이 쓰신 글 :
:



: #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);
:  }
:

+ -

관련 글 리스트
6909 c++로 미로게임을 만들고 있는데, 어디가 문제인지.. 볼란도 1739 2014/11/15
6912     Re:c++로 미로게임을 만들고 있는데, 어디가 문제인지.. 볼란도 1662 2014/11/15
6911     Re:c++로 미로게임을 만들고 있는데, 어디가 문제인지.. 볼란도 1704 2014/11/15
6910     Re:c++로 미로게임을 만들고 있는데, 어디가 문제인지.. Intotheblue 1714 2014/11/15
Google
Copyright © 1999-2015, borlandforum.com. All right reserved.