Console prints out blank screen for combat scenario

Hello,

I am currently making my first text adventure game and have come across a dilemma. I can't seem to find out what is going on. It's a runtime error and I have isolated it to this part of my code. When I run it and enter '1' for the if statement, it prints blank screens. Any help is appreciated. Thanks!

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
        int choiceTwoStay=0;
        cout << "*What would you like to do?" << endl;
        cout << "\t >> Enter '1' to attack zombie with bat" << endl;
        cout << "\t >> Enter '2' to attack zombie with tampons" << endl;
        cout << "\t Enter '3' to cower because you are a pussy" << endl;
        cin >> choiceTwoStay;

        if (choiceTwoStay==1) {
        string weaponChoice = "bat";
        int zombieAHealth=30;
        system("clear");

        while(zombieAHealth>0); {

            cout << "Press enter to attack" << endl;
            cout << "..." << endl;
            cin.ignore();
            cin.get();
            system("clear");
            cout << endl;

            srand(time(0));
            int damageZombieA = rand()%(30-0 + 1) + 0;
            cout << "# You hit him with " << weaponChoice << " and do " << damageZombieA << " damage!" << endl;
            zombieAHealth=-damageZombieA;
            cout << "Zombie Health: " << zombieAHealth;
        }

        }
@h3y4w

Remove the semi-colon on 13.
Also, move the srand command out of the while loop. You could put it right after line 1.

Your not subtracting damageZomieA from zombieAHealth, but assigning it with a minus damageZomieA value. The correct way to subtract it, is zombieAHealth-=damageZombieA;

Note that the minus sign is now before the equal sign
Thank you so much! whitenite1 +1
Topic archived. No new replies allowed.