int main(int argc, const char * argv[])
{
while(1)
{
system("clear");
showMap();
char direction = getDirection();
switch (direction)
{
case 'w':
case 'W':
moveToUp();
break;
case 's':
case 'S':
moveToDown();
break;
case 'a':
case 'A':
moveToLeft();
break;
case 'd':
case 'D':
moveToRight();
break;
case 'q':
case 'Q':
printf("游戏结束!\n");
return 0;
default:
printf("输入错误,请重新输入!\n");
break;
}
}
return 0;
}
/**
* 显示地图
*/
void showMap()
{
for (int i = 0; i < 15; i ++)
{
for (int j = 0; j < 15; j ++)
{
printf("%c ",arr[i][j]);
}
printf("\n");
}
}