refactor: rewriting of Moon
This commit is contained in:
parent
f39d6b48cb
commit
38e5ed9bc7
|
@ -2,40 +2,38 @@ package sagittarius.model;
|
||||||
|
|
||||||
import com.badlogic.gdx.graphics.Color;
|
import com.badlogic.gdx.graphics.Color;
|
||||||
import com.badlogic.gdx.math.MathUtils;
|
import com.badlogic.gdx.math.MathUtils;
|
||||||
|
import com.badlogic.gdx.math.Vector2;
|
||||||
|
|
||||||
public class Moon extends Planet {
|
public class Moon extends Planet {
|
||||||
|
|
||||||
private Planet planet;
|
private Planet sun;
|
||||||
private float altitude;
|
private float altitude;
|
||||||
|
|
||||||
// ---------- CONSTRUCTORs ----------
|
// ---------- CONSTRUCTORs ----------
|
||||||
|
|
||||||
public Moon(Planet planet, float mass, float radius, float altitude) {
|
public Moon(Planet sun, float mass, float radius, float altitude, Color color) {
|
||||||
super(planet.position, mass, radius);
|
super(new Vector2(), mass, radius, color);
|
||||||
this.planet = planet;
|
this.sun = sun;
|
||||||
this.altitude = altitude;
|
this.altitude = altitude;
|
||||||
}
|
}
|
||||||
|
|
||||||
Moon(Planet planet, float mass, float radius, float altitude, Color color) {
|
|
||||||
super(planet.position, mass, radius, color);
|
|
||||||
}
|
|
||||||
|
|
||||||
// ---------- METHODs ----------
|
// ---------- METHODs ----------
|
||||||
|
|
||||||
void update(double deltaTime) {
|
@Override
|
||||||
|
public void act(float deltaTime) {
|
||||||
|
|
||||||
this.angle += 10.0f / altitude;
|
this.rotateBy(10.0f / this.altitude);
|
||||||
|
|
||||||
this.position.x = planet.position.x + altitude*MathUtils.cosDeg(angle);
|
this.setX(sun.getX() + this.altitude*MathUtils.cosDeg(this.getRotation()));
|
||||||
this.position.y = planet.position.y + altitude*MathUtils.sinDeg(angle);
|
this.setY(sun.getY() + this.altitude*MathUtils.sinDeg(this.getRotation()));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return the Planet which the Moon orbits.
|
* @return the Planet which the Moon orbits.
|
||||||
*/
|
*/
|
||||||
Planet getPlanet() {
|
Planet getSun() {
|
||||||
return this.planet;
|
return this.sun;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue