float t; float L; int numberOfFrames = 100; int ny = 4; int nx = 70; class Tile { int xIndex; int yIndex; Tile(int i,int j) { xIndex = i; yIndex = j; } void show() { push(); translate(L*(xIndex-nx/2),L*yIndex,-L/2); fill(0); stroke(255); strokeWeight(1.5); box(0.95*L,0.95*L,0.1*L); // a bit of space between tiles, and small z length pop(); } }; Tile [][] array = new Tile[nx][ny]; void setup(){ size(600,600,P3D); randomSeed(12345); L = 1.0*width/15; for(int i=0;i<nx;i++) for(int j=0;j<ny;j++) array[i][j] = new Tile(i,j); } void draw(){ //t = 1.0*mouseX/width; // to control time with mouse t = 1.0*(frameCount-1)/numberOfFrames; background(0); push(); translate(width/2,height/2); rotateX(0.85); rotateZ(0.4); for(int i=0;i<nx;i++) for(int j=0;j<ny;j++) array[i][j].show(); pop(); if(frameCount<=numberOfFrames) { saveFrame("fr###.gif"); } if(frameCount==numberOfFrames) { stop(); } }