Turn based game, move to next monster if current monster is dead

Hey guys, I'm trying to make a game which is kinda similar to pokemon
When my current monster is dead, the next monster will pop up
I'm trying to find a way to implement this function

This is my current code structure:
void battle(){

int attack = 10;
int enemyAttack = 15;
int playerHealth = 20;
int enemeyHealth = 100;
for (int i = 0; i<mPlayer->getMonsterSize();i++)
{
do{
playerHealth -= enemyAttack;
enemyHealth -= playerAttack;
} while (maxHealth >0 && enemyHealth>0);
}
}

So basically I have 6 monster in my monsterSize.
Can anyone please suggest a way to help me finish my game?

Cheers
You need a struct of Monsters that have an attack and a health.

1
2
3
4
5
6
7
8
9
10
11
struct Monster
{
   Monster()
    {
       health = 100;
       attack = 15;
     };

     int health;
     int attack;
};



Then, inside your battle function, you create an array of Monsters:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
void battle(){

Monster Monsters[6];
int attack = 10;
int enemyAttack = 15;
int playerHealth = 20;
int enemeyHealth = 100;
for (int i = 0; i<mPlayer->getMonsterSize();i++)
{
for(int x = 0; x < 6; x++)
{
do
{
  playerHealth -= Monster[x].attack;
  Monsters[x].health -= playerAttack;
}while (maxHealth >0 && enemyHealth>0);
} 
}
}
Sorry, I forgot to mention that I already have a monster array which is showed here getMonsterSize().
I also have a struct for attack health and other status like agility and strength
Topic archived. No new replies allowed.