#include <stdio.h>
#include <stdlib.h>
#include <conio.h>
#include <Windows.h>
int main()
{
int
x=4,y=5,i;
char
a[20][20]= {" ###
",
"
#*# ",
"
# # ",
"####o######",
"#*
oso *#",
"#####o#####",
"
# # ",
"
#*# ",
"
### ",
};
for(i=0;i<=8;i++)
puts(a[i]);
if(a[x+1][y]=='o'
&& a[x+2][y]!='#')
{
x++;
a[x-1][y]='
';
a[x][y]='s';
a[x+1][y]=
char h;
while(1)
{h=getch();
if(h=='s')
{'o';
}
if(a[x+1][y]=='
')
{
x++;
a[x][y]='s';
a[x-1][y]='
';
}
}
if(h=='w')
{
if(a[x-1][y]=='o'
&& a[x-2][y]!='#')
{
x--;
a[x+1][y]='
';
a[x][y]='s';
a[x-1][y]='o';
}
if(a[x-1][y]=='
')
{
x--;
a[x][y]='s';
a[x+1][y]='
';
}
}
if(h=='a')
{
if(a[x][y-1]=='o'
&& a[x][y-2]!='#')
{
y--;
a[x][y+1]='
';
a[x][y]='s';
a[x][y-1]='o';
}
if(a[x][y-1]=='
')
{
y--;
a[x][y]='s';
a[x][y+1]='
';
}
}
if(h=='d')
{
if(a[x][y+1]=='o'
&& a[x][y+2]!='#')
{
y++;
a[x][y-1]='
';
a[x][y]='s';
a[x][y+1]='o';
}
if(a[x][y+1]=='
')
{
y++;
a[x][y]='s';
a[x][y-1]='
';
}
}
system("cls");
for(i=0;i<=8;i++)
puts(a[i]);
continue;
}
system("pause") ;
return
0;
}
推箱子
最新推荐文章于 2023-10-03 09:51:33 发布