#include<stdio.h>
#include<stdlib.h>
int x , y ;
int h , w ;
int bx, by;
void start()
{
h =20;
w = 30;
x =0;
y=0;
bx=0;
by=y;
}
void show()
{
system("cls");
int i , j ;
for(i=0;i<h;i++)
{
for(j=0;j<w;j++)
{
if((x==i)&&(y==j))
printf("机");
else if((i==bx)&&(j==by))
{
printf("o");
}
else
printf(" ");
}
printf("\n");
}
}
void updatewithoutinput()
{
if(bx>-1)
bx--;
}
void updatewithinput()
{
char input;
if(kbhit())
{
input =getch();
if(input=='a')
{
y--;
if(y==-1)
y++;
}
if(input =='d')
{
y++;
if(y==31)
y--;
}
if(input=='w')
{
x--;
if(x==-1)
x++;
}
if(input == 's')
{
x++;
if(x==21)
x--;
}
if(input==' ')
{
bx=x-1;
by=y;
}
}
}
int main()
{
start();
while(1)
{
show();
updatewithoutinput();
updatewithinput();
}
return 0;
}