You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Jun 24, 2024. It is now read-only.
// A bunch of planets
Planet[] planets = new Planet[10];
// One sun (note sun is not attracted to planets (violation of Newton's 3rd Law)
Sun s;
// An angle to rotate around the scene
float angle = 0;
void setup() {
size(800, 800, Dome.RENDERER);
smooth();
// Some random planets
for (int i = 0; i < planets.length; i++) {
planets[i] = new Planet(random(0.1, 2), random(-width/2, width/2), random(-height/2, height/2), random(-100, 100));
}
// A single sun
s = new Sun();
}
void pre() {
for (int i = 0; i < planets.length; i++) {
// Sun attracts Planets
PVector force = s.attract(planets[i]);
planets[i].applyForce(force);
// Update and draw Planets
planets[i].update();
}
}
void draw() {
background(0);
// Setup the scene
lights();
translate(width/2, height/2, 300);
rotateY(angle);
// Display the Sun
s.display();
// All the Planets
for (int i = 0; i < planets.length; i++) {
planets[i].display();
}
}
// Called after rendering all the faces, but before the dome sphere,
// so it can be used to draw stuff on the corners of the screen.
void border() {
perspective();
camera();
background(255);
fill(0);
text("FPS: " + frameRate, 20, 20);
}
void post() {
// Rotate around the scene
angle += 0.003;
}
The text was updated successfully, but these errors were encountered:
Hi, it seems that you sketch is missing part of the code, you should have the definition of the class Planet somewhere, either down below in the main sketch code, or on a separate tab.
when i run this code i get this part of the code highlighted why?
Planet[] planets = new Planet[10];
/**
*
*
import codeanticode.planetarium.*;
// A bunch of planets
Planet[] planets = new Planet[10];
// One sun (note sun is not attracted to planets (violation of Newton's 3rd Law)
Sun s;
// An angle to rotate around the scene
float angle = 0;
void setup() {
size(800, 800, Dome.RENDERER);
smooth();
// Some random planets
for (int i = 0; i < planets.length; i++) {
planets[i] = new Planet(random(0.1, 2), random(-width/2, width/2), random(-height/2, height/2), random(-100, 100));
}
// A single sun
s = new Sun();
}
void pre() {
for (int i = 0; i < planets.length; i++) {
// Sun attracts Planets
PVector force = s.attract(planets[i]);
planets[i].applyForce(force);
// Update and draw Planets
planets[i].update();
}
}
void draw() {
background(0);
// Setup the scene
lights();
translate(width/2, height/2, 300);
rotateY(angle);
// Display the Sun
s.display();
// All the Planets
for (int i = 0; i < planets.length; i++) {
planets[i].display();
}
}
// Called after rendering all the faces, but before the dome sphere,
// so it can be used to draw stuff on the corners of the screen.
void border() {
perspective();
camera();
background(255);
fill(0);
text("FPS: " + frameRate, 20, 20);
}
void post() {
// Rotate around the scene
angle += 0.003;
}
The text was updated successfully, but these errors were encountered: