Should I use a loop of some sort?

I am increasing the speed of my game object when the total number of them reaches a certain amount as follows:

if(GameController.count >= 10)
        {
            speed = -6;
        }
        if (GameController.count >= 20)
        {
            speed = -7;
        }
        if (GameController.count >= 30)
        {
            speed = -8;
        }
        if (GameController.count >= 40)
        {
            speed = -9;
        }
        if (GameController.count >= 50)
        {
            speed = -10;
        }
        if (GameController.count >= 60)
        {
            speed = -11;
        }
        if (GameController.count >= 70)
        {
            speed = -12;
        }
        if (GameController.count >= 80)
        {
            speed = -14;
        }
        if (GameController.count >= 90)
        {
            speed = -16;
        }
        if (GameController.count >= 100)
        {
            speed = -18;
        }
        if (GameController.count >= 110)
        {
            speed = -20;
        }

This works but… I know there is a better way to do this but I am drawing a blank. Assistance would be appreciated.

Thank you

Not a loop but a mathematical formula to calculate ‘speed’ from ‘count’. There seems to be a pattern that you decrease ‘speed’ by 1 for each addition of 10 in count, and after a certain count you decrement 2 at each threshold. So something like

var tens = GameController.count / 10;
if (tens >= 8) {
    tens -= 8;
    speed = -(tens*2) - 14;
} else if (tens >= 1) {
    speed = -tens - 5;
}

Didn’t exactly test the formula but it should be pretty close to your original code unless i made an ‘off by 1’ mistake or such.

if (GameController.count %10==0)
{
speed --;
}

an_Wolverine: when I try your code, speed decrements by one after every 10 but after every 11th it increments. So my speed starts at -5, then goes to -6 for one enemy, then back to -5 and so on… Will try NoseKills and repost.

Thanks guys, really appreciate the info!