Decide your total star count. Divide it into segments. For example, out of 100 total stars:
- 10 Blue Star Hard
- 30 White Star Medium
- 60 Red Star Soft
Code:
//can make enum StarColour
int BLUE = 0;
int WHITE = 1;
int RED = 2;
//can make enum StarFocus
int HARD = 0;
int MEDIUM = 1;
int SOFT = 2;
int i = 0;
for (i = 0; i < blueHardTotal; i++)
{
PlaceStar(BLUE, HARD);
}
for (i = blueHardTotal; i < blueHardTotal + whiteMediumTotal; i++)
{
PlaceStar(WHITE, MEDIUM);
}
for (i = whiteMediumTotal; i < whiteMediumTotal + redSoftTotal; i++)
{
PlaceStar(RED, SOFT);
}
This takes you through index [0] to [99] in segments.
P.S. There is nothing inefficient about this; and if you make the Totals compile-time constants, then the compiler should unroll the loops, thereby avoiding all conditionals.
If you want a more elegant way:
int[,] totals; //index in here by colour and focus, e.g. totals[RED, SOFT]
int i = 0;
for (int c = 0; c < COLOUR_COUNT; c++)
{
for (int f = 0; f < FOCUS_COUNT; f++)
{
int max = i + totals[c, f];
while (i < max)
{
PlaceStar(c, f);
i++;
}
}
}