My game made by boredom

What about my mini-game has a lot of potential if you ask i built it in 10-15 minutes , i really had fun doing it

#include <iostream>

using namespace std;

int main()
{
int enemlife = 100; //his life
char options;
int yourlife = 100; // my life
int dmg = 5; //damage
cout << "Somebody Attacks" << endl;
cout << "LIFE:" << enemlife << endl;
cout << "YOUR LIFE:" << yourlife << endl;
cout << "What you gonna do?" << endl;
cout << "ATTACK [a] , SURRENDER[b]" << endl;
cin >> options;
switch(options)
{
case 'a':
while (enemlife > 1)
{
cout << "The enemy lost -10 life , you lost " << dmg << endl;
enemlife -= 10;
yourlife = yourlife - dmg;
cout << "ENEMY LIFE: " << enemlife << endl;
cout << "YOUR LIFE: " << yourlife << endl;
cin >> options;
if (enemlife == 50)
{
cout << "================================================" << endl;
cout << "The enemy has streghten the attack now he has +5" << endl;
cout << "================================================" << endl;
dmg = 10;
}
else if (enemlife == 10)
{
cout << "You WON" << endl;
cout << "+1 credites" << endl;
break;
}
}
break;
case 'b' :
cout << "You surrendered" << endl;
cout << "-1 credites" << endl;
break;
default:
cout << "ERROR" << endl;
}

return 0;
}
Well, I like the surprise twist ending where you can lose or gain "credites". I always wanted one of those. :)
I could make a shop but you know , what to put there
add some randomness, e.g. https://en.cppreference.com/w/cpp/numeric/random/random_device/operator()

1
2
std::random_device rd;
int k = rd() % 10 + 1;  // random number from 1 to 10, inclusive 


Humans love mystery and chance. Currently your game plays out exactly the same way every time.
Oh i didn't knew about randomness
case 'b' is not correctly entered after 'a' has already been previously entered, due to your loop logic.
Last edited on
Topic archived. No new replies allowed.