Nested For loop Grouping
Hi Everyone,
I'm making a procedural City generator using nested for loops;
public Regions[] regions;
for (int x = 0; x < gridX; x++)
{
for (int z = 0; z < gridZ; z++)
{
if (x < gridX/region && z < gridX/ region) <--- what i need to replace
}
}
I have done quite a bit of work on it now but what i want to add next is regions, and i cant figure out the math in my head.
In the example image I could just get the x and z's below and above half but I would like to be able to add as many regions as I want and for it to calculate groups similar to the image above.
maybe using a percentage or something? i dunno my mind has gone black from looking at it so much...
Thanks in advance!
Follow this Question
Related Questions
LeanTween - For Loop Help 0 Answers
For Loop looping out of Loop Condition 1 Answer
Can someone explain what IEnumerators and for statements are? 1 Answer
,Code in loop simultaneously executing on members of array rather than iterating one at a time 1 Answer
if ALL items in array are something 1 Answer