jeudi 3 septembre 2015

What would be a better thing to use than an if statement for checking a value?

I wan't to replace my if statement with something that is constantly checking what the ehealth is and will carry out the function when ehealth is 0 or below and then break.

    cout <<"Oh no the enemy attacked you"<<endl;
    health = health - (eattack - defence);
    cout <<"Your health is now "<< health << endl;
    system("PAUSE");
    system("CLS");

    cout <<"it's your turn to attack now" <<endl;
    ehealth = ehealth - (attack - edefence);
    cout <<"the enemies health is " << ehealth;
    if (ehealth < 0)
    {
        cout<<"you have defeated the enemy";

    }
    cout <<"the enemy will now attack";

Aucun commentaire:

Enregistrer un commentaire