I had this working reasonably well several months ago but I must have forgotten to save the project. I had the moon orbiting the earth and the earth orbiting the sun with minimal flicker. I’ve read through many posts but cannot relate the answers to my project. What have I forgotten?
// The PShape object
PShape earth;
float orbitx, orbity;
float radius = 100;
float angle = 0.0;
int i = 0;
int timeEnd;
void setup()
{
size(600, 600, P2D);
// Create the earth as a PShape
earth = createShape(ELLIPSE, 0, 0, 50, 50);
earth.setStroke(color(0, 0, 255));
earth.setFill(color(0, 0, 255));
Haha, that doesn’t mean you withdrew your post, but that I withdrew mine, which I did because I thought I had misunderstood your question.
If you want to get rid of the flickering, you could either do that, or put the code for drawing outside of the if-statement (so translate and shape). Both of those options won’t be smooth though, so if you want that, you could just get rid of that condition all together.
Thank you Schred, raron and Hyperion65 for your replies.
I thought that I had to set up a timed event to trigger the Draw() function in the same way as other languages but it seems that I don’t. I’ll experiment further.
By the way, I found my original code, silly me saved it under some obscure name that I’d forgotten.
I just confirmed that all I need to do is move the translate and shape functions outside of the if loop, as suggested. Thanks again.