#include <stdio.h>
#include <stdlib.h>
#include <conio.h>
void show(int arr[10][10])
{
system("cls");
int i,j;
for(i=0;i<10;i++)
{
for(j=0;j<10;j++)
{
printf("%c ",arr[i][j]);
}
printf("\n");
}
}
void changij(int arr[10][10], int pi, int pj) {
}//changij
int main(void)
{
char eat=' ';
char inwall=' ';
char point=15;
int arr[10][10]={
{eat,eat,eat,eat,eat,eat,eat,eat,eat,eat},
{inwall,eat,eat,eat,inwall,eat,eat,eat,eat,eat},
{inwall,eat,inwall,eat,inwall,eat,eat,eat,inwall,eat},
{inwall,eat,eat,eat,inwall,eat,eat,inwall,eat,eat},
{inwall,eat,inwall,eat,inwall,inwall,eat,eat,inwall,eat},
{eat,eat,inwall,eat,eat,eat,eat,eat,inwall,eat},
{eat,inwall,inwall,inwall,eat,inwall,inwall,eat,inwall,eat},
{eat,eat,inwall,eat,eat,inwall,inwall,inwall,inwall,eat},
{inwall,eat,inwall,inwall,eat,eat,eat,inwall,eat,eat},
{inwall,inwall,inwall,inwall,inwall,inwall,eat,eat,eat,inwall}
};
inwall='*';
int i=0, j=0;
int pi=0, pj=0;
char ch=-32;
char store=eat;
char wall=inwall;
char oldch=14;
int k=0;
arr[pi][pj]=point;
show(arr);
for(;;)
{
if(ch!=-32)
oldch=ch;
ch=getch();
if(ch==-32)
continue;
if((ch=='l' || ch==77) && pj<9)
{
point=62;
if(ch==oldch)
{
if(k==1)
{
if(pi==0)
arr[pi][pj]=22;
else if(pi==9)
arr[pi][pj]=21;
else
arr[pi][pj]=16;
}
else
arr[pi][pj]='-';
store=arr[pi][pj+1];
if(store==wall);
else
pj++;
if(store==' ' || store=='-')
k=0;
else
k=1;
}//move
}//(ch=='l' || ch==77) && pj<9
if((ch=='j' || ch==75) && pj>0)
{
point=60;
if(ch==oldch)
{
if(k==1)
{
if(pi==0)
arr[pi][pj]=22;
else if(pi==9)
arr[pi][pj]=21;
else
arr[pi][pj]=16;
}
else
arr[pi][pj]='-';
store=arr[pi][pj-1];
if(store==wall);
else
pj--;
if(store==' ' || store=='-')
k=0;
else{
//printf("걸림");
//system("pause");
//arr[pi][pj]=16;
k=1;
}
}//move
}//if
if((ch=='i' || ch==72) && pi>0)
{
point=30;
if(ch==oldch)
{ if(k==1)
{
if(pj==0)
arr[pi][pj]=25;
else if(pj==9)
arr[pi][pj]=23;
else
arr[pi][pj]=16;
}
else
arr[pi][pj]='|';
store=arr[pi-1][pj];
if(store==wall);
else
pi--;
if(store==' ' || store=='|')
k=0;
else{
//printf("걸림");
//system("pause");
//arr[pi][pj]=16;
k=1;
}
}//move
}//if
if((ch=='k' || ch==80) && pi<9)
{
point=31;
if(ch==oldch)
{ if(k==1)
{
if(pj==0)
arr[pi][pj]=25;
else if(pj==9)
arr[pi][pj]=23;
else
arr[pi][pj]=16;
}
else
arr[pi][pj]='|';
store=arr[pi+1][pj];
if(store==wall);
else
pi++;
if(store==' ' || store=='|')
k=0;
else{
//printf("걸림");
//system("pause");
//arr[pi][pj]=16;
k=1;
}
}//move
}//if
arr[pi][pj]=point;
show(arr);
}//for
system("pause");
return 0;
}