Need help !!
in
Processing with Other Languages
•
2 years ago
i am having an error about : unexpected token void. i ve been looking for hours in search of the problem. here is my code
// creating orbitsPlanets objects
orbitPlanets Mercury;
orbitPlanets Venus;
orbitPlanets Earth;
orbitPlanets Mars;
orbitPlanets Jupiter;
orbitPlanets Saturn;
orbitPlanets Uranus;
orbitPlanets Neptune;
orbitPlanets Pluto;
orbitPlanets Venus;
orbitPlanets Earth;
orbitPlanets Mars;
orbitPlanets Jupiter;
orbitPlanets Saturn;
orbitPlanets Uranus;
orbitPlanets Neptune;
orbitPlanets Pluto;
void setup()
{
size(640,600,P3D); // size
AssignPlanetObjects(); // declaring and assigning new objects
}
{
size(640,600,P3D); // size
AssignPlanetObjects(); // declaring and assigning new objects
}
void draw()
{
sunDraw();
planetsUpdate();
planetsDisplay();
}
/* Drawing sun*/
public void sunDraw()
{
pushMatrix();
translate(width/2,height/2);
stroke(0);
fill(249,250,3);
ellipse(0,0,20,20);
popMatrix();
}
/* function updating the planets's attributes*/
{
pushMatrix();
translate(width/2,height/2);
stroke(0);
fill(249,250,3);
ellipse(0,0,20,20);
popMatrix();
}
/* function updating the planets's attributes*/
public void planetsUpdate()
{
Mercury.update();
Venus.update();
Earth.update();
Mars.update()
Jupiter.update();
Saturn.update();
Uranus.update();
Neptune.update();
Pluto.update();
}
{
Mercury.update();
Venus.update();
Earth.update();
Mars.update()
Jupiter.update();
Saturn.update();
Uranus.update();
Neptune.update();
Pluto.update();
}
/* function that displays the movement of planets*/
public void planetsDisplay()
{
Mercury.Display();
Venus.Display();
Earth.Display();
Mars.Display();
Jupiter.Display();
Saturn.Display();
Uranus.Display();
Neptune.Display();
Pluto.Display();
}
/* Function that declares and assigns new object*/
public void AssignPlanetObjects()
{
Mercury = new orbitPlanets(60.0,30.0,0.0);
Venus = new orbitPlanets(64.0,50.0,177.0);
Earth = new orbitPlanets(70.0,56.0,23.5);
Mars = new orbitPlanets(73.0,46.0,25.0);
Jupiter = new orbitPlanets(86.0,150.0,3.0);
Saturn = new orbitPlanets(96.0,130.0,27.0);
Uranus = new orbitPlanets(160.0,122.0,98.0);
Neptune = new orbitPlanets(230.0,198.0,30.0);
Pluto = new orbitPlanets(280.0,20.0,118.0);
}
==============================================================================
/* orbitingPlanets class*/
public class OrbitPlanets
{
private float R; // property classes
private float d;
private float acceleration;
private float velocity;
private float tilt;
private float theta;
private float w = 0.8;
private float t = 2;
private float angle = 0;
public OrbitPlanets(float distanceFromSun,float diameter,float t) // constructor
{
R = distanceFromSun;
d = diameter;
acceleration = 0.0
velocity = 0.0
tilt = t;
theta = 0;
}
public void update()
{
// increment angle for x-axis rotation of the planets
angle += (frameCount*2);
// increment theta for circular motion
{
private float R; // property classes
private float d;
private float acceleration;
private float velocity;
private float tilt;
private float theta;
private float w = 0.8;
private float t = 2;
private float angle = 0;
public OrbitPlanets(float distanceFromSun,float diameter,float t) // constructor
{
R = distanceFromSun;
d = diameter;
acceleration = 0.0
velocity = 0.0
tilt = t;
theta = 0;
}
public void update()
{
// increment angle for x-axis rotation of the planets
angle += (frameCount*2);
// increment theta for circular motion
theta += (w*t);
// centripetal acceleration
acceleration += (R * sqrt(w));
// velocity
velocity += (R * w);
}
public void display()
{
// rotate planets around x-axis
rotateX(radians(angle));
// rotate the planet at a tilt degree
rotate(radians(tilt));
// before rotation and translation, the state of the matrix is saved using pushMatrix() and popMatrix()
pushMatrix();
// orbit
rotate(radians(theta));
// translate out distance
translate(R,0);
// change height of the camera with mouseY
camera(30.0, mouseY, 220.0, // eyeX, eyeY, eyeZ
0.0, 0.0, 0.0, // centerX, centerY, centerZ
0.0, 1.0, 0.0); // upX, upY, upZ
fill(255);
ellipse(0,0,diameter,diameter); // drawing ellipse
popMatrix();
}
}
1