diff --git a/GravityBallCode/GravityBallCode.pde b/GravityBallCode/GravityBallCode.pde index df2493b..fb9ef0d 100644 --- a/GravityBallCode/GravityBallCode.pde +++ b/GravityBallCode/GravityBallCode.pde @@ -1,38 +1,50 @@ //declare variables -float x, y, velX, velY, diam; +int count = 30; +float [] x= new float [count]; +float [] y= new float [count]; +float [] velY= new float [count]; +float [] diam= new float [count]; +float [] a= new float [count]; void setup() { //set size of canvas - size(800, 600); + size(800, 600); //set size //initialize variables - x = width/2; - y = height/2; - diam = 80; - velX = random(-5, 5); - velY = random(-5, 5); +int i=0; //set local variable + + while(i= width) { - velX = -abs(velX); //if the ball hits the right wall, assign x velocity the negative version of itself - } else if (x - diam/2 <= 0) { - velX = abs(velX); //if the ball hits the left wall, assign x velocity the positive version of itself - } - if (y + diam/2 >= height) { - velY = -abs(velY); - } else if (y - diam/2 <= 0) { - velY = abs(velY); - } +if(y[i]>=height){ + velY[i]=-abs(velY[i]); +y[i]=height; //change y direction when it hits the bottom +} +i++; +} } \ No newline at end of file