//This should rotate an image in a random pattern at 90 degree turns.
PImage b;
void setup()
{
size(500,500);
frameRate(10);
b = loadImage("dino.png");
}
void draw ()
{
int a;
float x,y;
x=width/2;
y=height/2;
for(a=0;a<20;a++)
{
x=random(-100,400);
y=random(-100,400);
pushMatrix();
{
translate(x,y);
rotate(radians(90));
image(b,x,y);
rotate(radians(90));
image(b,x,y);
rotate(radians(90));
image(b,x,y);
rotate(radians(90));
image(b,x,y);
popMatrix();
}
}
noLoop();
}
//Same code, with notes.
ReplyDeletePImage b;
void setup()
{
//int a;
//float x,y; //random function returns a float (a number with a decimal point,) so we must have float vars
size(500,500);
frameRate(10);
//PImage b; //create an image object
b = loadImage("dino.png"); //set source file
/*for(a=0;a<50;a++)
{
x=random(-100,400);
y=random(-100,400);
image(b,x,y); //draw images at random points
}*/
}
void draw ()
{
int a;
float x,y; //random function returns a float (a number with a decimal point,) so we must have float vars
x=width/2;
y=height/2;
for(a=0;a<20;a++)
{
x=random(-100,400);
y=random(-100,400);
//image(b,x,y); //is this outside a function?
pushMatrix();
{
translate(x,y); //move the matrix to the middle of the screen
rotate(radians(90)); //rotate the matrix
image(b,x,y);
rotate(radians(90));
image(b,x,y);
rotate(radians(90));
image(b,x,y);
rotate(radians(90));
image(b,x,y);
popMatrix();
}
}
noLoop();
}