refactor: rewriting of Planet, now extends Actor
This commit is contained in:
parent
5de61a169d
commit
0c843bdea1
|
@ -5,42 +5,49 @@ import com.badlogic.gdx.graphics.g2d.Batch;
|
|||
import com.badlogic.gdx.graphics.g2d.BitmapFont;
|
||||
import com.badlogic.gdx.graphics.glutils.ShapeRenderer;
|
||||
import com.badlogic.gdx.math.Vector2;
|
||||
import com.badlogic.gdx.scenes.scene2d.Actor;
|
||||
|
||||
public class Planet extends Entity {
|
||||
public class Planet extends Actor {
|
||||
|
||||
// ---------- ATTRIBUTEs ----------
|
||||
|
||||
private float radius = 10;
|
||||
private BitmapFont fontDebug;
|
||||
private float radius;
|
||||
private float mass;
|
||||
|
||||
// ---------- CONSTRUCTORs ----------
|
||||
|
||||
public Planet(Vector2 position, float mass, float radius) {
|
||||
super(position, mass);
|
||||
this.radius = radius;
|
||||
}
|
||||
|
||||
public Planet(Vector2 position, float mass, float radius, Color color) {
|
||||
this(position, mass, radius);
|
||||
this.color = color;
|
||||
super();
|
||||
this.setPosition(position.x, position.y);
|
||||
this.radius = radius;
|
||||
this.mass = mass;
|
||||
this.setColor(color);
|
||||
}
|
||||
|
||||
// ---------- METHODs ----------
|
||||
|
||||
void render(ShapeRenderer shapeRenderer) {
|
||||
shapeRenderer.setColor(color);
|
||||
shapeRenderer.circle(this.position.x, this.position.y, radius);
|
||||
}
|
||||
@Override
|
||||
public void draw(Batch batch, float parentAlpha) {
|
||||
super.draw(batch, parentAlpha);
|
||||
fontDebug.draw(batch, "mass = " + mass, this.getX(), this.getY() + 15);
|
||||
fontDebug.draw(batch, "x = " + (int) this.getX() + ", y = " + (int) this.getY(), this.getX(), this.getY());
|
||||
}
|
||||
|
||||
void renderDebug(Batch batch, BitmapFont font) {
|
||||
font.draw(batch, "mass = " + mass, position.x, position.y + 15);
|
||||
font.draw(batch, "x = " + (int) position.x + ", y = " + (int) position.y, position.x, position.y);
|
||||
@Override
|
||||
public void drawDebug(ShapeRenderer shapes) {
|
||||
super.drawDebug(shapes);
|
||||
shapes.setColor(this.getColor());
|
||||
shapes.circle(this.getX(), this.getY(), this.radius);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the radius of the Planet.
|
||||
*/
|
||||
float getRadius() {
|
||||
public float getRadius() {
|
||||
return this.radius;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue