Hello I asked this question earlier but I think I put it on the wrong post so my apologies if I am repeating the same question, I will delete the other post:)
Anyway I have an array with random shapes I call via class I created my problem is when I choose to draw the random shape I have choosen it keeps picking a random shape then drawing it over and over again. I know the draw method is a loop, but I just cant figure out how to make it draw just one shape once instead of looping any help please
int numshapes = 3;
Shape[] shapes = new Shape[numshapes];- void setup()
{
shapes[0] = new Rectangle();
shapes[1] = new Circle();
shapes[2] = new Lined();
-
size(800,800);
} - void draw()
{ - shapes[int(random(0, shapes.length))].draw();
}
interface Shape
{
void draw();
}- class Rectangle implements Shape
{
void draw()
{
rect(25,25,25,25);
}
} - class Circle implements Shape
{
void draw()
{
ellipse(25,25,25,25);
}
} - class Lined implements Shape
{
void draw()
{
line(90,90,90,90);
}
}
1