Static and moving objects

Hello Guys,

I’m trying to do the following:

  • I’m drawing some circle by clicking with the mouse
  • I have a rect with a given coordinates
  • I’d like to move the rect with the keyboard

Every time I’m moving the rect the old ones are still visible. If I put a background this solve the problem, but this way the circles are dissapearing.

How can I move the rect withouth deleting the circles?

Thanks for your answers!

1 Like

Save the center and radius of the circles to a data structure, like an array-list, then every frame redraw the circles from the list.

3 Likes

Another way to solve this problem is to draw the circles onto a PGraphics mycircles, and display that image every draw frame with image(mycircles, 0, 0) before drawing your rect.

3 Likes