The code doesn't work, when I launch the code the balls are shown but they do not bounce of the side of the screen. I would appreciate it if someone could also help me create a code for each balls colliding with each other e.g when the balls hit each other they bounce off each other.
float [] x={0,100,400,0,300,50,800};
float [] y={100,200,500,50,0,30,600};
float [] dx={(3),(4),(6),(8),(10), (2), (5)};
float [] dy={ (5), (5), (3), (5), (1), (6), (8)};
float [] xx={3,4,6,8,10,2,5};
float [] yy={5,5,3,5,1,6,8};
float ballSize;
void setup() {
size(1920, 1080);
for (int i=0; i<=6; i++) {
xx[i]=xx[i]*2;
yy[i]=yy[i]*2;
}
}
void draw() {
noStroke();
ballSize= 60;
fill(0, 10);
rect(0,0, width, height);
fill(255);
ellipse(x[0],y[0], ballSize, ballSize);
ellipse(x[1],y[1], ballSize, ballSize);
ellipse(x[2],y[2], ballSize, ballSize);
ellipse(x[3],y[3], ballSize, ballSize);
ellipse(x[4],y[4], ballSize, ballSize);
ellipse(x[5],y[5], ballSize, ballSize);
ellipse(x[6],y[6], ballSize, ballSize);
for(int i=0; i<=6; i++) {
x[i]+=(dx[i]);
y[i]+=(dy[i]);
xx[i]+=0.0001;
yy[i]+=0.0001;
}
for (int i=0; i<=6; i++) {
if(x[i]>=width-50) {
dx[i]=(-xx[i]);
}
}
for (int i=0; i<6; i++) {
if (y[i]>=height-50) {
dy[i]=(yy[i]);
}
}
}