chance

Write your question here.
That's my ver yvery simple game. I wanna add some things, but i dont know how.
1.How to add a chance to do damage ? (for example 80%)
2.How not to allow the players to hit twice ?
3.How to make HP of the players to be on the top and just the number to change like that: 0HP 20HP
...
...
...
Player 1 won !
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
40
41
42
43
44
45
46
47
48
49
50
51
 #include <iostream>
#include <string>
#include <random>
#include <ctime>
#include <conio.h>
using namespace std;
int main()
{
	string PlayerOneName;
	string PlayerTwoName;
	cout << "Name Player 1:";
	cin >> PlayerOneName;
	cout << "Name Player 2:";
	cin >> PlayerTwoName;
	int PlayerOneHP = 100;
	int PlayerTwoHP = 100;
	default_random_engine randomDamage(time(0));
	uniform_int_distribution<int> Damage(1, 10);
	
	while ((PlayerOneHP > 0) && (PlayerTwoHP > 0))
	{
		char ch = _getch();
		int dm = Damage(randomDamage);
		if (ch == 'q')
		{
			cout << PlayerOneName << " did " << dm << " damage to " << PlayerTwoName << " ";
			PlayerTwoHP -= dm;
			if (PlayerTwoHP < 0){
				PlayerTwoHP = 0;
			}
			cout << PlayerTwoHP << endl;
		}
		else if (ch == 'p')
		{
			cout << PlayerTwoName << " did " << dm << " damage to " << PlayerOneName << " ";
			PlayerOneHP -= dm;
			if (PlayerOneHP < 0){
				PlayerOneHP = 0;
			}
			cout << PlayerOneHP << endl;
		}
	}
	if (PlayerOneHP == 0){
		cout << PlayerTwoName << " won the game!" << endl;
    }
	else {
		cout << PlayerOneName << " won the game!" << endl;
	}
	system("pause");
	return 0;
}
1. You can create another random int ranging 1 to 10, then multiply it to 10. And do something with the dmg variable
2. I dont get it
3. Maybe output, clearscreen, output, clearscreen after taking damage
Topic archived. No new replies allowed.