health - slimeAttack == health;
Is this where you are trying to reduce the amount of health on you, or the creature?
If it is reducing your health:
health = health - slimeAttack
If you were taking health away from the creature, just take the above code and change the variable names to match the health you are taking away from.
Another thing I would do is do an if statement to see if the creature, or you are dead
1 2 3 4
|
if(health <= 0)
{
//do some action saying you are dead or something
}
|
Or you could go with a while loop that constantly checks to see if your health does not equal or go below 0
1 2 3 4
|
while(health > 0)
{
//continue fighting
}
|
Just be sure to do this for the creature as well
1 2 3 4
|
while(health > 0 || creatureHealth > 0) //|| means logical or
{
//continue fighting
}
|
Another thing I will point out is using structures. Structures are similar to data type that can hold multiple pieces of data ex: ints, floats, doubles, etc...
I would use this to make up your multiple creature
1 2 3 4
|
struct Enemy{
int health;
//any other stats like maybe attack, defense, etc...
}; //be sure to add the semicolon
|
Then make the creature by doing this:
1 2 3
|
Enemy Slime;
Slime.health = 5;
//any other data that is in the struct like attack: Slime.attack = 2; etc...
|
This way you can make multiple creatures that can be called later.
1 2 3 4
|
Enemy Slime;
Enemy Goblin;
Enemy Bat;
//etc...
|
Here is a link for structures:
http://www.cplusplus.com/doc/tutorial/structures/
If any of this confuses you, just say so and I or someone else will try to clarify the information. I hope this helps you a little bit. Sorry I wouldn't know much about random generating numbers, but I believe someone else on here will help with that.