Math help for my game.

Recommended Videos

brainslurper

New member
Aug 18, 2009
940
0
0
So I am working on an iOS/HTML5 top down shooter. You are in a dark room with a flashlight, and you can only see what is on your flashlight. I am working on a way of making it more difficult as you progress. And the room is filled with bugs that kill you when they touch you. When you shoot you lose 10 points from your score, and your score increases 10 points per second. Most games get more difficult the further you get, but I want this to get more difficult based on the higher your score is.

So I need an equation that will take the score, and decide how much time is between each bug spawn. The problem is in my experience with this sort of thing you are counting down to something, a reverse clock simply counts up but subtracts it's value from a constant, but the constant can't exist because there is no end to this game. Thanks for any help you can offer!
 

brainslurper

New member
Aug 18, 2009
940
0
0
overpuce said:
You theoretically and logistically would need that constant wouldn't you? I mean you couldn't have an enemy spawn every .000001 seconds right?

v = spawn rate in .1 seconds
x = 15 second initial spawn time
y = score
z = .1 second counter

if (z >= v)
{
spawnenemy;
z = 0;
}
else
{
z = z + .1;
y = y + 10;
v = x - y/100;
if (v <= .1)
{
v = .1;
}
}

That would have it so the enemy spawns at a max of 15 seconds and a minimum of .1 seconds (still plenty fast).
Thank you so much!