Hi! I am trying to create a bunch of random circles to appear and then bounce around the edges of the screen. I got everything I wanted so far except the “checkEdge” function. I keep getting the error that says “The operator < is undefined for the argument type(s) int[], int[]”. I was reading online that you can change a boolean result to its corresponding int value but I was unsure of how to do that. I included the full code incase you needed to see it but the part I need help on is the very last function “void checkEdge”. Any help would be greatly appreciated!
int numParticle = 25;
int[] posX = new int[numParticle];
int[] posY = new int[numParticle];
int[] radius = new int[numParticle];
int[] dirX = new int[numParticle];
int[] dirY = new int[numParticle];
color[] randomColor = new color[numParticle];
void setup() {
size(500,500);
colorMode(HSB);
for (int i = 0; i < numParticle; i++) {
posX[i] = int(random(500));
posY[i] = int(random(500));
radius[i] = int(random(100));
dirX[i] = int(random(1,5));
dirY[i] = int(random(1,5));
randomColor[i] = color(random(255), random(255), random(255));
}
}
void draw() {
background(255);
drawParticles();
update();
checkEdge();
}
void drawParticles() {
noStroke();
for(int i =0; i < numParticle; i++) {
fill(randomColor[i]);
ellipse(posX[i], posY[i], radius[i], radius[i]);
}
}
void update() {
for(int i=0; i < numParticle; i++) {
posX[i] += dirX[i];
posY[i] += dirY[i];
}
}
void checkEdge() {
if(posX > width-radius || posX < radius) dirX = -dirX;
if(posY < radius || posY > height - radius) dirY = -dirY;
}