EDIT: I've got a while loop in my code, just now when player 1 goes to have his/her second attack the hp is reset to 99,
#include <conio.h>
#include <iostream>
using namespace std;
int main()
{
int p1attack, p2attack, p1hp, p2hp;
char attack;
p1hp = 99;
p2hp = 99;
system("TITLE Game.");
while(p1hp > 0 && p2hp > 0)
{
cout << "Player 1 (HP:" << p1hp << ") Press 'A' to attack : ";
cin >> attack;
switch(attack)
{
case 'a':
case 'A':
srand ( time(NULL) );
p1attack = rand() % 99 + 1;
cout << "You hit " << p1attack << "!";
break;
default:
cout << endl << "INVALID SELECTION!";
break;
}
p2hp -= p1attack;
cout << endl << endl << "Player 2 (HP:" << p2hp << ") Press 'A' to attack : ";
cin >> attack;
switch(attack)
{
case 'a':
case 'A':
srand ( time(NULL) );
p2attack = rand() % 99 + 1;
cout << "You hit " << p2attack << "!" << endl;
break;
default:
cout << endl << "INVALID SELECTION!";
break;
p1hp -= attack;
}
}
getch();
}