xxxxxxxxxx
//Setting up objects
Orbit1 myOrbit1;
Orbit2 myOrbit2;
Orbit3 myOrbit3;
Timer timer1;
Timer timer2;
void setup() {
size(400, 400);
myOrbit1 = new Orbit1(color(241, 196, 15), 15, 5);
myOrbit2 = new Orbit2(color(241, 196, 15), 50, 50);
myOrbit3 = new Orbit3(color(241, 196, 15), 20, 15);
timer1 = new Timer(2000);
timer1.start();
timer2 = new Timer(5000);
timer2.start();
}
void draw() {
background(0);
background(0);
myOrbit1.orbit();
myOrbit1.display();
if (timer1.isFinished()) {
myOrbit2.orbit();
myOrbit2.display();
}
if (timer2.isFinished()) {
myOrbit3.orbit();
myOrbit3.display();
}
if (mouseX > 0 & mouseX < width & mouseY > 0 & mouseY < height) {
myOrbit1.begin();
}
}
//Code was discected from given link: http://www.openprocessing.org/sketch/25994
class Orbit1 {
float xpos;
//float xspeed;
float ypos;
//float yspeed;
color c;
float csize;
float radius;
float vr;
float stuff;
boolean on = false;
boolean off = false;
// The Constructor is defined with arguments.
Orbit1(color tempC, float tempradius, float tempsize) {
c = tempC;
radius = tempradius;
vr = sqrt(2*800/sq(radius));
xpos = width/2;
ypos = (height/2)-radius;
csize = tempsize;
stuff = 0;
}
void display() {
if (on==true) {
stroke(255);
fill(20, 231, 165);
rect(90, 95, 20, 10);
stroke(0);
fill(c);
ellipseMode(CENTER);
ellipse((xpos*1.5)-200, (ypos*1.5)-200, csize, csize);
//loop();
}
//} else if (mouseX < 0.0 & mouseX > width & mouseY < 0.0 & mouseY > height) {
//noLoop();
//}
}
//Constraints on how the object orbits
void orbit() {
stuff = stuff + vr/radius;
xpos = width/2-radius*sin(stuff);
ypos = height/2-radius*cos(stuff);
}
void begin() {
on = true;
}
void fart() {
off = true;
}
}
//Code was discected from given link: http://www.openprocessing.org/sketch/25994
class Orbit2 {
float apos;
//float xspeed;
float bpos;
//float yspeed;
color c;
float csizeo;
float oradius;
float vro;
float stuffo;
// The Constructor is defined with arguments.
Orbit2(color tempC, float temporadius, float tempsize) {
c = tempC;
oradius = temporadius;
vro = sqrt(2*800/sq(oradius));
apos = width/2;
bpos = (height/2)-oradius;
csizeo = tempsize;
stuffo = 0;
}
void display() {
if (mouseX > 0 & mouseX < width & mouseY > 0 & mouseY < height) {
stroke(255);
fill(20, 231, 165);
rect(190, 270, 20, 10);
stroke(0);
fill(c);
ellipseMode(CENTER);
ellipse(apos, bpos+75, csizeo, csizeo);
}
}
void orbit() {
stuffo = stuffo + vro/oradius;
apos = width/2-oradius*sin(stuffo);
bpos = height/2-oradius*cos(stuffo);
}
}
//Code was discected from given link: http://www.openprocessing.org/sketch/25994
class Orbit3 {
float jpos;
//float xspeed;
float kpos;
//float yspeed;
color c;
float csizeh;
float hradius;
float vrh;
float stuffh;
// The Constructor is defined with arguments.
Orbit3(color tempC, float temphradius, float tempsize) {
c = tempC;
hradius = temphradius;
vrh = sqrt(2*800/sq(hradius));
jpos = width/2;
kpos = (height/2)-hradius;
csizeh = tempsize;
stuffh = 0;
}
void display() {
if (mouseX > 0 & mouseX < width & mouseY > 0 & mouseY < height) {
stroke(255);
fill(20, 231, 165);
rect(317, 126, 15, 5);
stroke(0);
fill(c);
ellipseMode(CENTER);
ellipse(jpos+125, kpos-70, csizeh, csizeh);
}
}
void orbit() {
stuffh = stuffh + vrh/hradius;
jpos = width/2-hradius*sin(stuffh);
kpos = height/2-hradius*cos(stuffh);
}
}
class Timer {
int savedTime; // When Timer started
int totalTime; // How long Timer should last
Timer(int tempTotalTime) {
totalTime = tempTotalTime;
}
// Starting the timer
void start() {
// When the timer starts it stores the current time in milliseconds.
savedTime = millis();
}
// The function isFinished() returns true if 5,000 ms have passed.
// The work of the timer is farmed out to this method.
boolean isFinished() {
// Check how much time has passed
int passedTime = millis()- savedTime;
if (passedTime > totalTime) {
return true;
} else {
return false;
}
}
}