How to Reset values?
Hello, I have a simple game below:
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 37 38 39
|
#include <iostream>
#include <string>
using namespace std;
int level;
int attack = 100;
int monster = 500;
string answer;
int main()
{
for(int i = 0; i < 10; i++) // 10 Rounds of fighting
{
cout << "Enter 'attack' to attack monster" << endl;
cin >> answer;
if(answer == "attack") //Attack the monster
{
monster -= attack;
cout << "You attacked monster! " << attack << " damage" << endl;
cout << endl;
system("pause");
system("cls");
}
if ( monster <= 0 ) //Defeat monster = 1 level
{
level += 1;
cout << "You leveled up! " << endl;
cout << endl;
system("pause");
system("cls");
}
}
return 0;
}
|
Here is my question ..
How can you reset the monster's value back to 500 after you
leveled up ??
1 2 3 4 5 6 7 8 9 10 11 12
|
if ( monster <= 0 ) //Defeat monster = 1 level
{
level += 1;
cout << "You leveled up! " << endl;
monster = 500
cout << endl;
system("pause");
system("cls");
}
}
return 0;
}
|
Hello, Thank you for your reply, it helped me a lot! :)
Git gud
Git gud? Is that like the opposite of אױ װײ
Topic archived. No new replies allowed.