Java collision issues

Joined
Dec 9, 2019
Messages
6
Reaction score
0
My program doesn't work properly as in the collision doesn't work can someone please fix my code and explain where i went wrong?


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=xx*2;
yy=yy*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+=(dx);
y+=(dy);
xx+=0.0001;
yy+=0.0001;
}
for (int i=0; i<=6; i++) {
if(x>=width-50) {
dx=(-xx);
}
}
for (int i=0; i<6; i++) {
if (y>=height-50) {
dy=(yy);
}
}
}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,009
Latest member
GidgetGamb

Latest Threads

Top