I have a while loop with a condition inside called card1Hp and it is a new instance variable defined at the top of the class called Game.
public int card1Hp = 100;
public int card2Hp = 80;
public int card3Hp = 90;
public int card4Hp = 70;
and there's a method in the class with a while loop:
while(card1Hp > 0)
I have a method in the class that generates a specified random number for me where I can go:
someVar= Game.getRandIntBetween(1,5);
and it generates randVar = 1 or 2 or 3 or 4 or 5. Is there any way I can put this into my while loop condition. Basically I want it to be:
while(card1Hp > 0)
replaced with some kind of way like this
while(card(randVar)Hp > 0)
I know that isn't the way to write it in java but that's the effect I want to try and generate the random number I want in my cardHp. What's a good way to achieve this? I plan for hundreds of cardhp variables in my game as well to randomize.
Aucun commentaire:
Enregistrer un commentaire