Teacher posted an assignment: we had to make 100 random shapes. He gave the class a quick example in class:
void setup()
{
size(200,200);
frameRate(1);
}
void draw()
{
background(0);
int i=1;
while(i<=100)
{
ellipse(int(random(200)),int(random(200)),20,20);
i++;
}
}
I decided to do another simple one, but with Pokeballs (my parents decided to skip the creative department):
void setup()
{
size(500, 500);
frameRate(1);
}
void draw()
{
background(0);
int a=1;
float b=random(width);
float c=random(height);
while (a<=100)
{
//pushStyle();
//noStroke();
fill(255, 0, 0);
bezier(b, c, b+5, c-25, b+35, c-25, b+40, c);
fill(255);
bezier(b, c, b+5, c+25, b+35, c+25, b+40, c);
//popStyle();
ellipse(b+20, c, 12, 12);
a++;
}
}
Yet when I run my program, I get a single Pokeball that moves randomly. I experimented with moving background() to void draw(), and ended up getting a never-ending loop. How can I make my program similar to my teachers'?
1