1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36
|
for(;;) {
cout << " TELL ME WHERE YOU WANT TO GO : UP, DOWN, LEFT, RIGHT " << endl;
cin >> way;
if(way.compare("UP") || way.compare("up")) {
updateRoom(0, -1, xPos, yPos);
}else if(way.compare("DOWN") || way.compare("down")) {
updateRoom(0, 1, xPos, yPos);
}else if(way.compare("LEFT") || way.compare("left")) {
updateRoom(-1, 0, xPos, yPos);
}else if(way.compare("RIGHT") || way.compare("right")) {
updateRoom(1, 0, xPos, yPos);
}
}
return 0;
}
void updateRoom(int x, int y, int &posx, int &posy) {
posx += x;
posy += y;
system("CLS");
cout << x;
cout << y;
cout << posx;
cout << posy;
cout << endl;
}
|