I am making an Arkanoid-like game, but I want the levels to be procedurally generated. The gameboard is 16x12. The bricks are 1 unit wide, but they are not that high. I’m not sure how exactly to measure exactly how much of one unit they are? And I’m not sure how to handle this when trying to procedurally generate them. Can anyone help me with figuring out some of the math on this? I’m still a little unsure of the whole Unity unit’s and how they compare to pixels, etc. Thanks!
You would use a loop inside a loop to represent X and Y coordinates. then change your scale for shape
void Start () {
GameObject g;
//add more colors for more layers
Color[] colors = new Color[]{
Color.white,Color.grey,Color.blue,
Color.green,Color.magenta,Color.red,
Color.cyan,Color.yellow,Color.black};
int rows = 16;
float w = 1f;
float h = .3f;
int i = colors.Length;
while(i>0){i--;
int i2 = rows;
while(i2>0){i2--;
g = GameObject.CreatePrimitive(PrimitiveType.Cube);
g.transform.renderer.material.color = colors*;*
_ g.transform.position = new Vector3(wi2,hi,0);_
-
g.transform.localScale = new Vector3(w,h,1);*
-
}}*
-
}*