PDA

View Full Version : [AS3] Making First Flash Game


TheDarkTemplar
09-09-2009, 08:17 PM
I am making a game where two wizards battle back and forth based off of probabilities of using an attack. Here is the code I have so far:

var hp1=20;
var hp2=20;

while (hp2 > 0) {

if (Math.random()*100<21) {
gotoAndPlay(36);
hp2=hp2-5;
}
else {
gotoAndPlay(5);
hp2=hp2-2;
}


}
stop();

Frames 36-65 are a lightning attack and frames 5-35 are a fireball attack. I don't know how to get it to stop at the end of the attack clip and reset the while loop though so that it will only play the one attack each time. Also, the while loop doesn't seem to be working at all. It just keeps looping long after the HP should be at 0.

Please Help.