int circleSize;
float angle; // global variables
int a;
float change;
int xCenter;
int yCenter;
int nStroke;
boolean bInit;
float x;
float y;
float m;
float b;
void setup() {
size(800, 600);
bInit=true;
firstInit();
circleSize = 50;
change = 4;
nStroke = 1;
xCenter = width/4;
yCenter = height/4;
angle = 180;
a = 150;
b = 75;
background(255);
fill(255, 0, 0);
}
void draw() {
float x; // local variables
float y;
x = xCenter + a * cos(radians(angle));
y = yCenter + b * sin(radians(angle));
ellipse(x+270, y+270, circleSize, circleSize);
angle = angle + change;
if (angle-180 < -90 || angle-180 > 90) {
change = -change;
nStroke++;
}
switch(nStroke) {
case 1:
firstInit();
break;
case 2:
secondInit();
break;
}
}
void firstInit() {
if (bInit) {
bInit = false;
x = 100+90;
y = 21;
b = 300;
m = 400.0/200.0;
}
else {
x = x + change;
y = -m * -x + b-30;
stroke(0);
fill(0, mouseX, 128, random(121));
ellipse(x, y, 25, 25);
if (y < 150) {
nStroke++;
}
}
}
void secondInit() {
if (bInit) {
bInit = false;
// x = 100;
// y = 0;
// b = 30;
// m = 400.0/200.0;
}
else {
ellipse(x, y, 30, 30);
y = y + change;
if (y > 300) {
nStroke++;
bInit = true;
}
}
nStroke++;
}