View Full Version : Varying the number of enemies with score.
dcwoody
04-12-2005, 06:57 PM
I have half made half stolen a simple game in order to learn actionscript, it needs a lot of work especially on the graphics but I think I know how to do most of it.
I have attached the entire game.
I would like to know how to increase the number of enemies in line with the score.
I have tried looking in the tutorials for help with this and using a timer controlled event to increase the enemies instead of the score, but I can't make that work either.
Help is appreciated.
Update, I have not uploaded the game because its too big so you almost certainly can't help me with this information.
How are you meant to get anything useful in a max 20KB zip??
coolioman
04-15-2005, 02:23 PM
try this
// if the text box with the variable "score" reaches 15, it will bring the text box lwith the variable "men" up 1
if (score eq "15") {
men+=1;
}
// if the "men" text box has been brought up to 5, it will attach new man.
if(men eq "5")
// attach new man
attachMovie("man","newman"+level,level);
// set a random position
_root["newman"+level]._x = int(Math.random()*550);
_root["newman"+level]._y = int(Math.random()*400);
// increase level
level++;
}
ill try to make a sample .fla. By the way, what version of flash are you using?
dcwoody
04-15-2005, 05:39 PM
Flash 5 thanks for the help, thoough Im not sure it will (help)
coolioman
04-15-2005, 05:43 PM
good. I wrote that out in flash 5. by the way, if you have AIM you could send it to me from there.
Using the variable name level to denote depth is inadvisable, as it leads users into thinking of depths as levels and they are not levels. A level is an entirely different thing in Flash.
Also, the conditional syntax (the if statement) is malformed -- best to do a syntax check before posting code, coolioman.
I would also suggest that you use discrete variables for keeping track of the score and the number of men, assigning those values, as needed to variables expressly for the purpose of display -- and don't try to use the strings displayed for math opeations, i.e., keep your nbrScore and stgScore variables separate -- the first being and actual number, and periodically assigned to the string variable for display. The reason for that is, if the variable men contains the string "4", and you add 1 to it, it will equal the string "41", not the number 5 or the string "5".
I'm not clear on the specification, however. Are you looking to add new enemies the instant the score reaches certain values, or does the number of enemies increase only at the end of a cetain period of activity? In other words, is the evaluation occurring upon every user click or is the evaluation performed only after a certain amount of time has expired?
vBulletin® v3.7.1, Copyright ©2000-2009, Jelsoft Enterprises Ltd.