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.g2d.BitmapFont;
|
||||||
import com.badlogic.gdx.graphics.glutils.ShapeRenderer;
|
import com.badlogic.gdx.graphics.glutils.ShapeRenderer;
|
||||||
import com.badlogic.gdx.math.Vector2;
|
import com.badlogic.gdx.math.Vector2;
|
||||||
|
import com.badlogic.gdx.scenes.scene2d.Actor;
|
||||||
|
|
||||||
public class Planet extends Entity {
|
public class Planet extends Actor {
|
||||||
|
|
||||||
// ---------- ATTRIBUTEs ----------
|
// ---------- ATTRIBUTEs ----------
|
||||||
|
|
||||||
private float radius = 10;
|
private BitmapFont fontDebug;
|
||||||
|
private float radius;
|
||||||
|
private float mass;
|
||||||
|
|
||||||
// ---------- CONSTRUCTORs ----------
|
// ---------- 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) {
|
public Planet(Vector2 position, float mass, float radius, Color color) {
|
||||||
this(position, mass, radius);
|
super();
|
||||||
this.color = color;
|
this.setPosition(position.x, position.y);
|
||||||
|
this.radius = radius;
|
||||||
|
this.mass = mass;
|
||||||
|
this.setColor(color);
|
||||||
}
|
}
|
||||||
|
|
||||||
// ---------- METHODs ----------
|
// ---------- METHODs ----------
|
||||||
|
|
||||||
void render(ShapeRenderer shapeRenderer) {
|
@Override
|
||||||
shapeRenderer.setColor(color);
|
public void draw(Batch batch, float parentAlpha) {
|
||||||
shapeRenderer.circle(this.position.x, this.position.y, radius);
|
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) {
|
@Override
|
||||||
font.draw(batch, "mass = " + mass, position.x, position.y + 15);
|
public void drawDebug(ShapeRenderer shapes) {
|
||||||
font.draw(batch, "x = " + (int) position.x + ", y = " + (int) position.y, position.x, position.y);
|
super.drawDebug(shapes);
|
||||||
|
shapes.setColor(this.getColor());
|
||||||
|
shapes.circle(this.getX(), this.getY(), this.radius);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return the radius of the Planet.
|
* @return the radius of the Planet.
|
||||||
*/
|
*/
|
||||||
float getRadius() {
|
public float getRadius() {
|
||||||
return this.radius;
|
return this.radius;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue