I used the following formula to create the colors for the different rows in breakout. But I find myself repeating the if function 5 times to get 5 different colors. I was wondering if there is a more efficient way to do this without using so many if functions?
for (int j = 0; j < COLS; j++)
{
brick = newGRect(6 + (brickwd + brickspc) * j, 40 + (brickht + brickspc) * i, brickwd, brickht);
setFilled(brick, true);
add(window, brick);
if (i == 0)
{
setColor(brick, "black");
}
else if (i == 1)
{
setColor(brick, "red");
}
else if (i ==2)
{
setColor(brick, "orange");
}
else if (i == 3)
{
setColor(brick, "green");
}
else
{
setColor(brick, "blue");
}
}