Tealc
Oct 25, 2003, 03:33 PM
would appreciate any help, been at this since 1pm.....got the following:
my first problem, is that i have to make the map area 20x20 so if the player is on square 20,20 and clicks n to go north, an error message should display saying that s/he can't go any further
my second problem, is that when fatigue gets to 20 (after 20 movements) it is supposed to bring up a message saying that the player is too tired, which it does....but if n is input again it brings up the error message, as well as changing the coordinates (i dont want the player to move when fatigue is at 20)
#include <iostream>
using namespace std;
void main()
{
int x=6;
int y=6;
int max=20;
char action;
int iPlayerFatigue = 0;
char bp;
bp=7;
cout << "Hello and Welcome to lost island" << endl;
cout<< "Your current location is (" <<x<< "," <<y<< ")" << endl;
cout<<bp;
do
{
cout<<"What do you want to do?: " << endl; //outputs question
cin >> action; //user input
cout << ""<< endl;
switch (action)
{
case 't': cout << "You look around....there is nobody to talk to, try it next week." <<endl;
break;
case 'f': cout << "There is nobody to fight here." << endl;
break;
case 'p': cout << "There is nothing to pick up." <<endl;
break;
case 'd': cout << "You don't have anything to drop" <<endl;
break;
case 'n': cout << "Your current location is now (" <<x<< "," <<(y+1)<< ")" << endl;
y++;
iPlayerFatigue++;
break;
case 's': cout << "Your current location is now (" <<x<< "," <<(y-1)<< ")" << endl;
y--;
iPlayerFatigue++;
break;
case 'e': cout << "Your current location is now (" <<(x+1)<< "," <<y<< ")" << endl;
x++;
iPlayerFatigue++;
break;
case 'w': cout << "Your current location is now (" <<(x-1)<< "," <<y<< ")" << endl;
x--;
iPlayerFatigue++;
break;
case 'l' : cout << "Your fatigue is currently at " << iPlayerFatigue << endl;
break;
case 'r' : cout << "Your fatigue has been reduced by 5, it is now " <<(iPlayerFatigue = iPlayerFatigue - 5) << endl;
break;
case 'z' : cout << "You fall asleep..your fatigue is now 0 " << endl;
(iPlayerFatigue=0);
break;
case 'x': cout << "You are now leaving the game" << endl;
break;
default: cout << "Please enter a valid character" << endl;
}
if (iPlayerFatigue >=20)
switch (action)
{
case 'r' : cout << "Your fatigue has been reduced by 5, it is now " <<(iPlayerFatigue = iPlayerFatigue - 5) << endl;
break;
case 'z' : cout << "Your fatigue is now 0 " << endl;
(iPlayerFatigue=0);
break;
default : cout << "You are too tired, you should either rest (r) or sleep (z)" << endl;
break;
}
} while (action != 'x');
}
my first problem, is that i have to make the map area 20x20 so if the player is on square 20,20 and clicks n to go north, an error message should display saying that s/he can't go any further
my second problem, is that when fatigue gets to 20 (after 20 movements) it is supposed to bring up a message saying that the player is too tired, which it does....but if n is input again it brings up the error message, as well as changing the coordinates (i dont want the player to move when fatigue is at 20)
#include <iostream>
using namespace std;
void main()
{
int x=6;
int y=6;
int max=20;
char action;
int iPlayerFatigue = 0;
char bp;
bp=7;
cout << "Hello and Welcome to lost island" << endl;
cout<< "Your current location is (" <<x<< "," <<y<< ")" << endl;
cout<<bp;
do
{
cout<<"What do you want to do?: " << endl; //outputs question
cin >> action; //user input
cout << ""<< endl;
switch (action)
{
case 't': cout << "You look around....there is nobody to talk to, try it next week." <<endl;
break;
case 'f': cout << "There is nobody to fight here." << endl;
break;
case 'p': cout << "There is nothing to pick up." <<endl;
break;
case 'd': cout << "You don't have anything to drop" <<endl;
break;
case 'n': cout << "Your current location is now (" <<x<< "," <<(y+1)<< ")" << endl;
y++;
iPlayerFatigue++;
break;
case 's': cout << "Your current location is now (" <<x<< "," <<(y-1)<< ")" << endl;
y--;
iPlayerFatigue++;
break;
case 'e': cout << "Your current location is now (" <<(x+1)<< "," <<y<< ")" << endl;
x++;
iPlayerFatigue++;
break;
case 'w': cout << "Your current location is now (" <<(x-1)<< "," <<y<< ")" << endl;
x--;
iPlayerFatigue++;
break;
case 'l' : cout << "Your fatigue is currently at " << iPlayerFatigue << endl;
break;
case 'r' : cout << "Your fatigue has been reduced by 5, it is now " <<(iPlayerFatigue = iPlayerFatigue - 5) << endl;
break;
case 'z' : cout << "You fall asleep..your fatigue is now 0 " << endl;
(iPlayerFatigue=0);
break;
case 'x': cout << "You are now leaving the game" << endl;
break;
default: cout << "Please enter a valid character" << endl;
}
if (iPlayerFatigue >=20)
switch (action)
{
case 'r' : cout << "Your fatigue has been reduced by 5, it is now " <<(iPlayerFatigue = iPlayerFatigue - 5) << endl;
break;
case 'z' : cout << "Your fatigue is now 0 " << endl;
(iPlayerFatigue=0);
break;
default : cout << "You are too tired, you should either rest (r) or sleep (z)" << endl;
break;
}
} while (action != 'x');
}
