class Orbit {
//data
float theta;
int r;
int r2;
float t;
//constructor
Orbit (float tempTheta, int tempR, int tempR2, float tempT) {
theta=tempTheta;
r=tempR;
r2= tempR2;
t= tempT;
}
void move() {
// orbiting circle
ellipse (width/2 + cos(theta)*r2, height/2 + sin(theta)*r2, r, r);
//increment theta
//increase to speed up movement
theta += .05;
if (r<width-20) {
r++;
}
else {
r=r*-1;
}
}
}
//declare
Orbit orbit1;
Orbit orbit2;
Orbit orbit3;
Orbit orbit4;
void setup () {
size (400, 400);
smooth();
orbit1 = new Orbit (PI, 20, 150, .05);
orbit2 = new Orbit (0, 20, 150, .1);
}
void draw () {
background (0);
// orbiting circle
fill (0,250,0);
orbit1.move();
fill (250,0,0);
orbit2.move();
}