I have these worm things which are just a bunch of circles in a line that are falling down the screen and want to make it so that every time they go off screen they reset back to zero with a different amount of circles, is there a way I can change the how many numbers are stored in the array?
This is what I have so far
int [] num=new int [4];
int []numx=new int[4];
int rand =int(random(-2,7));
float xball=400;
float yball=200;
void setup() {
size(400, 400);
}
void draw() {
noStroke();
background(255);
for ( int i=0; i<num.length; i++)
{
fill(int(random(255)),int(random(255)),int(random(255)));
for( int j =0; j<numx.length;j++)
{
ellipse(numx[j],num[i], 40, 40);
num[i]+=rand;
rand =int(random(-2,7));
ellipse(xball,yball, 20, 20);
if (dist(xball, yball, numx[j], num[i])<=30)
println("you lose");
if (num[i]>=height)
{
for(i=0;i<num.length; i++)
num[i]=-50;
for ( j=0; j<numx.length; j++)
numx[j]=int(random(height));
}
}
}
if(keyPressed)
{
if (key ==CODED)
{
if (keyCode==LEFT)
xball-=10;
else if (keyCode == RIGHT)
xball+=10;
else if (keyCode ==UP)
yball-= 10;
else if (keyCode ==DOWN)
yball+=10;
}
}
}