Ellipse not moving

I used to know almost all the features in processing like a year ago, and now I decided to get back and try again. I just made a simple script telling the console to show a circle with some gravity, and everything works fine but one thing. The circle is redrawing every frame, but not deleting the old frames. Just copy the code and try for yourself. Is there anything i did wrong? I also tried this ecsact code, but with a rectangle instead of an ellipse and everything worked.

float gravity = 0;
float y = 180;

void setup(){
  size(640, 360);
  background(0);
}

 void draw(){
  ellipse(320, y, 10, 10);
  
  y = y + gravity;
  gravity = gravity + 0.4;
}
1 Like

background (0); at start of draw

1 Like

Thanks, it worked, but i still dont get why the rectangle works anyway.

you mean why the background (0); at start of draw solves the problem?

I replaced ellipse with rect and the same issue occurs. Are you positive you didn’t accidently changed something?

Hi Tobias,

180 is the start position for y.

We add the gravity to y which is initially 0.

Since we increase gravity over time, the shape accelerates.

Normally though we add vy to y and vy gets changed by gravity - see https://processing.org/examples/bouncybubbles.html

gravity is constant here, as it is in real life