Right now i’m just trying to create a basic box formation…I’ve been doing it the hard way like this:
void CreateBox(int i, int count)
{
if (i == 1)
{
boxX = 0;
boxY = 0;
}
else if (i == 2)
{
boxX = 1;
boxY = 0;
}
else if (i == 3)
{
boxX = 0;
boxY = 1;
}
else if (i == 4)
{
boxX = 1;
boxY = 1;
}
else if (i == 5)
{
boxX = 2;
boxY = 0;
}
else if (i == 6)
{
boxX = 2;
boxY = 1;
}
else if (i == 7)
{
boxX = 2;
boxY = 2;
}
else if (i == 8)
{
boxX = 0;
boxY = 2;
}
else if (i == 9)
{
boxX = 1;
boxY = 2;
}
else if (i == 10)
{
boxX = -1;
boxY = 0;
}
else if (i == 11)
{
boxX = -2;
boxY = 0;
}
else if (i == 12)
{
boxX = -1;
boxY = -1;
}
else if (i == 13)
{
boxX = -2;
boxY = -1;
}
else if (i == 14)
{
boxX = -2;
boxY = -2;
}
pos = new Vector2(boxX, boxY);
}
What is a formula I can use to achieve the same thing? It is basically a box with points that need to be spaced out in each direction in 1 while stay centered at the point of origin 0,0;