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.math.MathUtils;
|
||||
import com.badlogic.gdx.math.Vector2;
|
||||
|
||||
public class Moon extends Planet {
|
||||
|
||||
private Planet planet;
|
||||
private Planet sun;
|
||||
private float altitude;
|
||||
|
||||
// ---------- CONSTRUCTORs ----------
|
||||
|
||||
public Moon(Planet planet, float mass, float radius, float altitude) {
|
||||
super(planet.position, mass, radius);
|
||||
this.planet = planet;
|
||||
public Moon(Planet sun, float mass, float radius, float altitude, Color color) {
|
||||
super(new Vector2(), mass, radius, color);
|
||||
this.sun = sun;
|
||||
this.altitude = altitude;
|
||||
}
|
||||
|
||||
Moon(Planet planet, float mass, float radius, float altitude, Color color) {
|
||||
super(planet.position, mass, radius, color);
|
||||
}
|
||||
|
||||
// ---------- 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.position.y = planet.position.y + altitude*MathUtils.sinDeg(angle);
|
||||
this.setX(sun.getX() + this.altitude*MathUtils.cosDeg(this.getRotation()));
|
||||
this.setY(sun.getY() + this.altitude*MathUtils.sinDeg(this.getRotation()));
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the Planet which the Moon orbits.
|
||||
*/
|
||||
Planet getPlanet() {
|
||||
return this.planet;
|
||||
Planet getSun() {
|
||||
return this.sun;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue