thanks man, I am only doing this as a side prject so I would think there would be alot of errors. If you could help me with my first problem it would be much appreciated but anyway thanks alot :D
I would suggest putting lines 75-86 into a function. Then call that function any time you want to allow the user to go somewhere. I would suggest changing the variable named level to location. This would be more indicative of it's use. level is easily confused with lvl.
To give you an idea:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
constint max_locations = 3;
const string loc_names[max_locations] = { "Town", "Arena", "Shop" };
int move_to_location (int curr_loc)
{ int loc;
cout << "Where do you want to go?";
for (int i=0; i<max_locations; i++)
if (i != curr_loc) // Don't display if already there
cout << i << " " << loc_names[i] << endl;
cin >> loc;
while (loc < 0 || loc >= max_locations || loc == curr_loc)
{ cout << "Not a valid location. Try again" << endl;
cin >> loc;
}
cout << "You are in " << loc_names[loc] << endl;
return loc; // caller will update curr_location from returned value
}
thanks that really helps alot :D I only have two wuestions, 1. whats does const mean? and 2. I am going to try to get the player to fight in the arena but I want the enemys to ranomly generate so for arguements sake lets say there are 5 diffrent enemys how do I randomly get one to fight the player? thanks alot man your helping me out alot :D
1) The const modifier means that the value can not be changed.
2)
1 2 3 4 5 6 7
// At the beginning of main
srand(time(NULL)); // Initialize the random number generator
// Where you want the fight to happen
constint max_enemies = 5;
int enemy;
enemy = rand() % max_enemies; // Generate a random value from 0 - 4