We are about to switch to a new forum software. Until then we have removed the registration on this forum.
void setup() {
frameRate(20);
}
double mercuryAngle = random(0, TWO_PI);
double venusAngle = random(0, TWO_PI);
double earthAngle = random(0, TWO_PI);
double marsAngle = random(0, TWO_PI);
double earthMoonAngle = random(0, TWO_PI);
double jupiterAngle = random(0, TWO_PI);
double saturnAngle = random(0, TWO_PI);
double uranusAngle = random(0, TWO_PI);
double neptuneAngle = random(0, TWO_PI);
double plutoAngle = random(0, TWO_PI);
double sunspot1Angle = random(0, TWO_PI);
double sunspot2Angle = random(0, TWO_PI);
double halleyAngle = random(0, TWO_PI);
double nemesisAngle = random(0, PI);
double days = 0;
float A = 525;
float B = 220;
float p = 1;
int n = 0;
float sunX = 500*random(1,1.001);
float sunY = 500*random(1,1.001);
float nemesunX = sunX;
float nemesunY = sunY;
void draw() {
background(0);
noStroke();
size(1000, 1000);
fill(20, 20, 20);
ellipse(sunX, sunY, 1000*2, 1000*2);
fill(0, 0, 0);
ellipse(sunX, sunY, 491*2, 482*2);
fill(255, 255, 255);
textSize(30);
text("Welcome to Solar System 6.0.orbit! ", 300, 100);
textSize(12);
text("Time Info", 20, 20);
text("| Earth Days Completed: "+int(days/6.75), 40, 40);
text("| Earth Weeks Completed: "+int(days/6.75/7), 40, 60);
text("| Earth Years Completed: "+int(days/365.24/6.75), 40, 80);
text("| Earth Centuries Completed: "+int(days/365.24/6.75/100), 40, 100);
for(int i = 0; i <= 1000; i++){
double size = random(0, 1.5);
ellipse(random(0, 1000), random(0, 1000), size, size);
}
fill(40, 40, 40);
ellipse(sunX, sunY, 181*2, 189*2);
fill(10, 10, 0);
ellipse(sunX, sunY, 92*2, 99*2);
fill(21, 21, 0);
ellipse(sunX, sunY, 58*2, 58*2);
fill(34, 34, 0);
ellipse(sunX, sunY, 42*2, 42*2);
fill(50, 50, 0);
ellipse(sunX, sunY, 29*2, 29*2);
fill(124, 124, 0);
ellipse(sunX, sunY, 25*2, 25*2);
fill(255, 255, 0);
ellipse(sunX, sunY, 40, 40);
fill(58, 58, 11);
ellipse(sunX, sunY, 1, 1);
mercuryAngle += 0.14;
venusAngle -= 0.07;
earthAngle += 0.035;
marsAngle += 0.0145001;
earthMoonAngle += 0.26;
jupiterAngle += 0.00497;
saturnAngle += 0.00218;
uranusAngle += 0.00118;
neptuneAngle += 0.000487202;
plutoAngle += 0.000487201;
halleyAngle += 0.119119;
nemesisAngle += 0.119119/5;
days += 365.24*0.035;
fill(201, 201, 201);
ellipse(sunX+41*cos(mercuryAngle), sunY+46*sin(mercuryAngle), 4, 4);
text("Mercury",sunX+41*cos(mercuryAngle),sunY+46*sin(mercuryAngle));
fill(128, 128, 0);
ellipse(sunX+56*cos(venusAngle), sunY+56*sin(venusAngle), 6, 6);
text("Venus",sunX+56*cos(venusAngle),sunY+56*sin(venusAngle));
fill(0, 109, 255);
ellipse(sunX+70*cos(earthAngle), sunY+73*sin(earthAngle), 6.001, 6.001);
text("Earth",sunX+70*cos(earthAngle),sunY+73*sin(earthAngle));
fill(200, 0, 0);
ellipse(sunX+104*cos(marsAngle), sunY+98*sin(marsAngle), 5, 5);
text("Mars",sunX+104*cos(marsAngle),sunY+98*sin(marsAngle));
fill(100, 100, 100);
ellipse((sunX+70*cos(earthAngle))+8*cos(earthMoonAngle), (sunY+73*sin(earthAngle))+8.29*sin(earthMoonAngle), 3.5, 3.5);
fill(200, 93, 29);
ellipse(sunX+174*cos(jupiterAngle), sunY+189*sin(jupiterAngle), 19, 19);
text("Jupiter",sunX+174*cos(jupiterAngle)+9,sunY+189*sin(jupiterAngle));
fill(200, 143, 0);
ellipse(sunX+213*cos(saturnAngle), sunY+249*sin(saturnAngle), 18, 18);
text("Saturn",sunX+213*cos(saturnAngle)+8.5,sunY+249*sin(saturnAngle));
fill(151, 200, 255);
ellipse(sunX+357*cos(uranusAngle), sunY+387*sin(uranusAngle), 13, 13);
text("Uranus",sunX+357*cos(uranusAngle)+6.5,sunY+387*sin(uranusAngle));
fill(0, 0, 200);
ellipse(sunX+468*cos(neptuneAngle), sunY+421*sin(neptuneAngle), 11, 11);
text("Neptune",sunX+468*cos(neptuneAngle)+6,sunY+421*sin(neptuneAngle));
fill(151, 151, 151);
ellipse(sunX+498*cos(plutoAngle), sunY+418*sin(plutoAngle), 3.6, 3.6);
text("Pluto",sunX+498*cos(plutoAngle),sunY+418*sin(plutoAngle));
fill(255, 255, 212);
ellipse((sunX-100)+125*cos(halleyAngle), sunY+89*sin(halleyAngle), 3, 3);
text("Halley's Comet",(sunX-90)+125*cos(halleyAngle),sunY+89*sin(halleyAngle));
//Code works up until this point
if ( (0) <= n*TWO_PI/(A-B) && (PI/2) <= (PI/2) )
{
fill(255, 55, 25);
ellipse((nemesunX-10)+A*cos(nemesisAngle), nemesunY+B*sin(nemesisAngle), 5, 5);
text("NEMESIS",(nemesunX)+A*cos(nemesisAngle),nemesunY+B*sin(nemesisAngle));
A = A - p;
B = B + p;
n += 1;
}
if ( (PI/2) <= n*TWO_PI/(A-B) <= (PI) )
{
fill(255, 55, 25);
ellipse((nemesunX-10)+A*cos(nemesisAngle), nemesunY+B*sin(nemesisAngle), 5, 5);
text("NEMESIS",(nemesunX)+A*cos(nemesisAngle),nemesunY+B*sin(nemesisAngle));
A = A + p;
B = B - p;
n += 1;
}
if ( (PI) <= n*TWO_PI/(A-B) <= (3* PI/2) )
{
fill(255, 55, 25);
ellipse((nemesunX-10)+A*cos(nemesisAngle), nemesunY+B*sin(nemesisAngle), 5, 5);
text("NEMESIS",(nemesunX)+A*cos(nemesisAngle),nemesunY+B*sin(nemesisAngle));
A = A - p;
B = B + p;
n += 1;
}
if ( (3*PI/2) <= n*TWO_PI/(A-B) <= (TWO_PI) )
{
fill(255, 55, 25);
ellipse((nemesunX-10)+A*cos(nemesisAngle), nemesunY+B*sin(nemesisAngle), 5, 5);
text("NEMESIS",(nemesunX)+A*cos(nemesisAngle),nemesunY+B*sin(nemesisAngle));
A = A + p;
B = B - p;
n += 1;
}
if ( n*TWO_PI/(A-B) >= (TWO_PI) )
{
n = 0;
}
} //Draw Loop
Answers
edit post, highlight code, press ctrl-o to format
OK. Maybe I wasn't clear on this point. I've run the code on sketchpad before but currently can't get in to the website. Now I know the sketch works up until where I commented. So it should run in openprocessing. But it doesn't. I can't even seem to get openprocessing to recognize the variable declaration.
Format the code
Please format your code. Edit your post (gear on top right side of any of your posts), select your code and hit ctrl+o. Leave an empty line above and below your block of code. Details here: https://forum.processing.org/two/discussion/15473/readme-how-to-format-code-and-text
Kf
Ctrl-o won't work on the system I'm using. I get an error message saying that the operation has been canceled due restrictions on the computer (?). It's a public library computer. Is there an alternative way to format the code. I'd be willing to crunch it line by line if need be. I'm interested in this project and learning more Processing features.
It's done
Ok, few things to do:
Replace all variable definitions from double to float.
Move the size() function call from
draw()
tosetup()
where it belongs.Finally, check your conditionals. For instance, what is the meaning of this?
if ( (3*PI/2) <= n*TWO_PI/(A-B) <= (TWO_PI) )
Maybe you need the AND operator
if ( (3*PI/2) <= n*TWO_PI/(A-B) && n*TWO_PI/(A-B) <= (TWO_PI) )
You need to fix three conditionals which have this ill interpretation.
I did not tested in OpenProcessing but after those fixes it works in java.
Kf