So here I have a problem of trying to get objects to collide with each other so now i'm going to try create a new processing application with a ball bouncing of the sides of the walls. then ill add another ball to hit that ball and make that reflect to. So it will be like two ball colliding in the middle of the screen and bouncing back to the wall then so on and so on.
Progress so far. CODE:
int ball = 20;
float xpos = 0;
float ypos = 200;
int xdirection = 10;
void setup(){
size(500,500);
smooth();
}
void draw(){
background(0);
xpos = xpos + xdirection;
if(xpos > width){
xdirection = xdirection * - 1;
}
if(xpos < 0){
xdirection = xdirection * -1;
}
ellipse(xpos+ball, ypos+ball,ball,ball);
fill(255);
}
No comments:
Post a Comment