PDA

View Full Version : Increasing quantity


EdgeIcon
03-06-2009, 03:21 PM
Hello,

I'm sure that this is simple..
Just curious how to go about increasing a variable by 1 for every 10 points on a score timer ( called 'myTimer' )

that variable will be used to determine the quantity of "enemies" on the screen.

I already have this game of mine working fine, i just would like the number of enemies to increase every 10 points

Thanks

EightySeven
03-06-2009, 07:07 PM
numberSpawned = BASE_NUMBER + (Math.ceil(score/10))-1;

kkbbcute
03-08-2009, 03:24 AM
numberSpawned = BASE_NUMBER + (Math.ceil(score/10))-1;

You might also want to put an if/else statement after that to limit how high your numberSpawned can go, as having like 200 enemies on the screen is going to lag the game and remove any fun for the player at some point.

EdgeIcon
03-08-2009, 05:03 AM
You might also want to put an if/else statement after that to limit how high your numberSpawned can go, as having like 200 enemies on the screen is going to lag the game and remove any fun for the player at some point.

would you mind helping me out on how that if/then statement should look?

i keep overloading the flash player.. ( doing it wrong i suppose :P )

kkbbcute
03-08-2009, 07:24 AM
would you mind helping me out on how that if/then statement should look?

i keep overloading the flash player.. ( doing it wrong i suppose :P )

It's really quite simple.


var limitOfSpawn:Number = //Insert number here

if (numberSpawned > limitOfSpawn) {
numberSpawned = limitOfSpawn
}

cjx3711
03-09-2009, 10:12 AM
or you could put this:
an if else statement that controls the entire thing

var limitOfSpawn:Number = //Insert number here
if (numberSpawned > limitOfSpawn) {
// do nothing
} else {
numberSpawned = BASE_NUMBER + (Math.ceil(score/10))-1;
}

kkbbcute
03-09-2009, 10:22 AM
or you could put this:
an if else statement that controls the entire thing

var limitOfSpawn:Number = //Insert number here
if (numberSpawned > limitOfSpawn) {
// do nothing
} else {
numberSpawned = BASE_NUMBER + (Math.ceil(score/10))-1;
}

Erms, if you spawned more than the limit, do nothing? A typo there.