//记录点s小人坐标 四个终点坐标 箱子坐标
#include <stdio.h>
#include <stdlib.h>#include <windows.h>
void tuixiangzi()
{
//system("color 0c");
char a[50][50]={" ### ",
" #*# ",
" # # ",
"###########O#######",
"#* OS O*#",
"###########O#######",
" # # ",
" #*# ",
" ### ",
};
//------------------------------------------------
int i,x,y,p,q,n,m,r,t,o,u;
char ch;
x=4;y=11;p=4;q=1;n=4;m=17;r=1;t=11;o=7;u=11;
for(i=0;i<=8;i++)
puts(a[i]);
//--------------------------------------------
while(a[4][1]!='@' || a[4][17]!='@' || a[1][11]!='@' || a[7][11]!='@')
{
ch=getch();
//-------------------------------------------
if(ch=='s')
{
if(a[x+1][y]!='#')
{
a[x][y]=' ';
x++;
if(a[x][y]=='O')
{
a[x][y]=' ';
if(a[x+1][y]=='*')
{a[x+1][y]='@';}
else
{a[x+1][y]='O';}
}
a[x][y]='S';
}
}
//----------------------------------------
if(ch=='w')
{
if(a[x-1][y]!='#')
{
a[x][y]=' ';
x--;
if(a[x][y]=='O')
{
a[x][y]=' ';
if(a[x-1][y]=='*')
{a[x-1][y]='@';}
else
{a[x-1][y]='O';}
}
a[x][y]='S';
}
}
//----------------------------------
if(ch=='a')
{
if(a[x][y-1]!='#')
{
a[x][y]=' ';
y--;
if(a[x][y]=='O')
{
a[x][y]=' ';
if(a[x][y-1]=='*')
{a[x][y-1]='@';}
else
{a[x][y-1]='O';}
}
a[x][y]='S';
}
}
//----------------------------------
if(ch=='d')
{
if(a[x][y+1]!='#')
{
a[x][y]=' ';
y++;
if(a[x][y]=='O')
{
a[x][y]=' ';
if(a[x][y+1]=='*')
{a[x][y+1]='@';}
else
{a[x][y+1]='O';}
}
a[x][y]='S';
}
}
//--------------------------
if(ch=='o')
{
system("cls");
printf("BYE!\n");
Sleep(3000);
system("cls");
ui();
}
system("cls");
printf("----------------------------w s a d 上下左右 o离开--------------------------------------\n");
for(i=0;i<=8;i++)
puts(a[i]);
}
system("cls");
printf("You Win!\n");
// system("start file:///D:/QIN/c/changyouwuxian/yanhua2/yanhua2.exe");
printf("输入o离开\n");
ch=getch();
if(ch=='o')
{
system("cls");
printf("BYE!\n");
system("cls");
ui();
}
return 0;
}