#include <stdio.h>
#include <stdlib.h>
#include <windows.h>
#include <conio.h>
#define xy 13

void right(int arr[xy][xy],int *x,int *y,int inwall,int wall,int *remember)
{
     if(arr[*x][(*y)+1]==inwall || arr[*x][(*y)+1]==wall)
     {}
     else
     {
         *remember=arr[(*x)][++(*y)];
     }
}//right
void left(int arr[xy][xy],int *x,int *y,int inwall,int wall,int *remember)
{
     if(arr[*x][(*y)-1]==inwall || arr[*x][(*y)-1]==wall)
     {}
     else
     {
         *remember=arr[(*x)][--(*y)];
     }
}//left
void up(int arr[xy][xy],int *x,int *y,int inwall,int wall,int *remember)
{
     if(arr[(*x)-1][(*y)]==inwall || arr[*x][(*y)]==wall)
     {}
     else
     {
         *remember=arr[--(*x)][(*y)];
     }
}//up
void down(int arr[xy][xy],int *x,int *y,int inwall,int wall,int *remember)
{
     if(arr[(*x)+1][(*y)]==inwall || arr[(*x)+1][(*y)]==wall)
     {}
     else
     {
         *remember=arr[++(*x)][(*y)];
     }
}//down
void movef(char cur,int arr[xy][xy],int *x,int *y,int inwall,int wall,int *remember)
{   
     switch(cur)
     {
     case 77:
          right(arr,x,y,inwall,wall,remember);
          break;
     case 75:
          left(arr,x,y,inwall,wall,remember);
          break;   
     case 72:
          up(arr,x,y,inwall,wall,remember);
          break;        
     case 80:
          down(arr,x,y,inwall,wall,remember);
          break;        
     }
}
void change(int d)
{
     int space=0;
     int wall=1;
     int my=2;
     int you=3;
     int inwall=4;
     int move=5;
     int setcolor[10]={1,8,13,10,15,15,15};
    
     HANDLE hConsole;

     hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
     SetConsoleTextAttribute(hConsole, setcolor[d]);

     char str[10][3]={"  ","■","●","●","▧","◈","●"};
     printf("%s",&str[d][0]);
}//change

int lencheak(int maxlen)
{  
    int i;
    for(i=0;i*i<maxlen;i++);
   
    return i-1;
}//lencheak
int main(void)
{
    int x;
    int y;
    int remember=0;
    int space=0;
    int wall=1;
    int inwall=4;
    int my=2;
    int you=3;
    int move=5;
    int arr[xy][xy];
    int maxlen;
    int stagenum;
    int i=0;
    int j=0;
    int data=0;
    char cur=-32;
    char recur=0;
    int zx;
    int zy;
    int zhit;
   
   
    //파일오픈 
    FILE *fp=fopen("stage1.txt","r");
    //파일오픈오류체크
    if(fp==NULL)
    {  
        puts("파일오픈 실패!");
        return -1;
        }
    //최대길이받기   
    fscanf(fp,"%d",&maxlen);
    //먼지 모르겟지만 필요없는 숫자 제거
    fscanf(fp,"%d",&stagenum);

   
    //배열에 map읽어서 집어넣기
    for(i=0;i<xy;i++)
    {
        for(j=0;j<xy;j++)
        {  
            fscanf(fp,"%d",&data);
            arr[i][j]=data;
        }
    }//for i
   
    //커서 초기치 집어넣기
    arr[xy/2][xy/2]=5;
   
    //커서 좌표값 잡기
    x=xy/2;
    y=x;
   
    //배열 출력하기
    while(1)
    {
            system("cls");
            for(i=0;i<xy;i++)
            {
               for(j=0;j<xy;j++)
               {
                  change(arr[i][j]);
               }
               printf("\n");
            }//for i
           
            for(;;)
            {
               if(cur!=-32)
               recur=cur;
       
               cur=getch();
       
               if(cur!=-32)
               break;
            }
            arr[x][y]=remember;
            movef(cur,arr,&x,&y,inwall,wall,&remember);
            arr[x][y]=move;

    } 
    system("pause");
    return 0;
}



List of Articles
번호 제목 글쓴이 날짜 조회 수
공지 글쓰기는 하루 5개, 댓글은 10개만 가능합니다. 좋은아빠되기 2019.02.15 293
공지 키보드 화살표값 출력 좋은아빠되기 2016.11.19 1067
공지 원하는 좌표에 값 출력하기 좋은아빠되기 2016.11.19 2380
공지 Python(파이썬) 학습 자료 PDF 1 file 좋은아빠되기 2014.12.10 10251
공지 dev C++ 텍스트 색상변경 WinApi사용(textcolor 대용) 좋은아빠되기 2014.06.07 4707
공지 DEV-C++ 기본 코드 좋은아빠되기 2013.06.19 8208
공지 무료 C++ 컴파일러(윈도우용) DEV-C++ 좋은아빠되기 2013.06.18 18937
공지 이클립스 C++ 설치 파일들 좋은아빠되기 2013.06.18 37826
110 정올 기초다지기(함수3-자가진단3) killerjack 2014.07.26 873
109 정올 기초다지기(함수3-자가진단2) killerjack 2014.07.26 579
108 정올 기초다지기(함수3-자가진단1) killerjack 2014.07.26 881
107 정올 기초다지기(aE007-함수2 7) killerjack 2014.07.26 984
106 정올 기초다지기(aE006-함수2 6) killerjack 2014.07.26 652
105 정올 기초다지기(aE005-함수2 5) killerjack 2014.07.26 631
104 정올 기초다지기(aE002-함수2 2) killerjack 2014.07.26 581
103 정올 기초다지기(함수2-자가진단8) killerjack 2014.07.26 733
102 정올 기초다지기(함수2-자가진단7) killerjack 2014.07.26 756
101 정올 기초다지기(함수2-자가진단6) killerjack 2014.07.26 669
100 정올 기초다지기(함수2-자가진단5) killerjack 2014.07.26 753
99 정올 기초다지기(함수2-자가진단4) killerjack 2014.07.12 807
98 정올 기초다지기(함수2-자가진단3) killerjack 2014.07.12 1105
97 정올 기초다지기(함수2-자가진단2) killerjack 2014.07.12 803
96 정올 기초다지기(함수2-자가진단1) killerjack 2014.07.12 888
95 정올 기초다지기(aD004-함수4) killerjack 2014.07.12 916
94 정올 기초다지기(aD003-함수3) killerjack 2014.07.12 799
» 세균전 복습 이번엔 내머리가 좀 많이 들어갓음 z키 기능 추가하고 복사 또는 이동 만들어야한다 killerjack 2014.07.05 658
92 세균전 복사하기 만들어야함 killerjack 2014.06.07 1101
91 dev C++ 입력키값 숫자로 알아보기 killerjack 2014.06.07 1315
Board Pagination Prev 1 ... 16 17 18 19 20 21 22 23 24 25 26 Next
/ 26