while (1) {
scanf("%c",&derection);
getchar();//scanf("%c",&ch);//吸收多余的\n
switch (derection) {
case 'w':
case 'W':
if (map[currentX-1][currentY]==street) {
personMove(map,currentX,currentY,currentX-1,currentY);
currentX--;
}
break;
case 's':
case 'S':
if (map[currentX+1][currentY]==street) {
personMove(map,currentX,currentY,currentX+1,currentY);
currentX++;
}
break;
case 'a':
case 'A':
if (map[currentX][currentY-1]==street) {
personMove(map,currentX,currentY,currentX,currentY-1);
currentY--;
}
break;
case 'd':
case 'D':
if (map[currentX][currentY+1]==street) {
personMove(map,currentX,currentY,currentX,currentY+1);
currentY++;
}
break;
case 'q':
case 'Q':
return 0;
break;
default:
break;
}
//重绘地图
printMap(map);
if (currentY==5) {
printf("恭喜你!走出迷宫~(づ ̄ 3 ̄)づ\n");
break;
}