Tuesday, March 1, 2011

Project 4- Arrays and shit!

/*

//This is what I used to make and save the images, I just changed the variables from 0 to 14 and saved as such.

int x;
int y;

size(600,600);
background(255,127,0); //background color
stroke(0, 255, 0); //define stroke color
fill(0,0,255); //define fill color


for(y=0;y<14;y++)
{
for(x=0;x<14;x++)
{
rect(x*30,y*30,20,20);
}
}

save("boxes14.jpg"); */

// and the actual code-

PImage boxes[]= new PImage[14]; //use array object as a "container" for all our images
int counter;


void setup()
{
size(500,500);
//load my faces in
for(int a=0;a<boxes.length;a++)
{
boxes[a]=loadImage("boxes"+a+".jpg");
println("loaded "+"boxes"+a+".jpg");
}
counter=0;

}


void draw()
{

//println(counter);
image(boxes[counter],mouseX,mouseY);

counter++;
if(counter>=boxes.length)
{
counter=0;
}

delay(10);
frameRate(20);

}