I'm messing around with some 3d programming and I'm trying to build a wall out of blocks but I can't figure out the best way to do it. I initially thought a for loop inside another for loop to place blocks in a row and then move up one space and run the row again but that gives me an insane amount of blocks since something funky is going on in the inner loop. I ALMOST got it but I got this really weird pattern where the first segment of the wall is missing the top and bottom block... Looks like this:
5x5
BBBB
B BBBB
B BBBB
B BBBB
BBBB
//this creates the x axis row of blocks fine.
var coords = [0,0,0]
var switch = 0;
for(var j=0; j<5; j++)
{
for(var i=0; i<5; i++){
placeBlock(coords[ coords[0],coords[1],coords[2] ])
if(switch==0) //this changes the direction the blocks are placed
coords[0]++;
else
coords[0]--;
}
coords[1]++; //add one to the y axis
if(flag==0)
flag=1
else
flag=0
}
[code]