fix: Player debug drawing
This commit is contained in:
parent
f921f922c0
commit
ccbdd559e1
|
@ -30,8 +30,9 @@ public class Planet extends Actor {
|
|||
@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());
|
||||
fontDebug.draw(batch, "radius=" + (int)radius, getX(), getY() + fontDebug.getCapHeight()*2);
|
||||
fontDebug.draw(batch, "mass=" + (int)mass, getX(), getY() + fontDebug.getCapHeight());
|
||||
fontDebug.draw(batch, "pos=" + (int)getX() + "," + (int)getY(), getX(), getY());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -1,9 +1,12 @@
|
|||
package sagittarius.model;
|
||||
|
||||
import com.badlogic.gdx.Gdx;
|
||||
import com.badlogic.gdx.Input.Keys;
|
||||
import com.badlogic.gdx.graphics.Color;
|
||||
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.graphics.glutils.ShapeRenderer.ShapeType;
|
||||
import com.badlogic.gdx.math.MathUtils;
|
||||
import com.badlogic.gdx.scenes.scene2d.Actor;
|
||||
|
||||
|
@ -12,17 +15,17 @@ public class Player extends Actor {
|
|||
// ---------- ATTRIBUTEs ----------
|
||||
|
||||
private Planet home;
|
||||
private Bow bow;
|
||||
// private Bow bow;
|
||||
private BitmapFont fontDebug = new BitmapFont();
|
||||
|
||||
// ---------- CONSTRUCTORs ----------
|
||||
|
||||
public Player(Planet home, Color color) {
|
||||
super();
|
||||
this.setSize(50, 100);
|
||||
this.setSize(100, 50);
|
||||
this.setRotation(MathUtils.random(360));
|
||||
this.setColor(color);
|
||||
this.setOrigin(25, 50);
|
||||
this.setOrigin(0, getHeight()/2);
|
||||
this.home = home;
|
||||
//this.bow = new Bow(this, true);
|
||||
}
|
||||
|
@ -32,7 +35,7 @@ public class Player extends Actor {
|
|||
@Override
|
||||
public void draw(Batch batch, float parentAlpha) {
|
||||
super.draw(batch, parentAlpha);
|
||||
fontDebug.draw(batch, "x = " + (int) this.getX() + ", y = " + (int) this.getY(), this.getX(), this.getY());
|
||||
fontDebug.draw(batch, "pos=" + (int)getX() + "," + (int)getY() , getX(), getY());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -40,14 +43,33 @@ public class Player extends Actor {
|
|||
super.drawDebug(shapes);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void drawDebugBounds(ShapeRenderer shapes) {
|
||||
if (!getDebug()) return;
|
||||
shapes.set(ShapeType.Line);
|
||||
if (getStage() != null) shapes.setColor(getStage().getDebugColor());
|
||||
|
||||
shapes.rect(getX(), getY() - getOriginY(),
|
||||
getOriginX(), getOriginY(),
|
||||
getWidth(), getHeight(),
|
||||
getScaleX(), getScaleY(),
|
||||
getRotation());
|
||||
shapes.line(home.getX(), home.getY(), getX(), getY());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void act(float dt) {
|
||||
super.act(dt);
|
||||
|
||||
this.setX(home.getX() + this.home.getRadius()*MathUtils.cosDeg(this.getRotation()));
|
||||
this.setY(home.getY() + this.home.getRadius()*MathUtils.cosDeg(this.getRotation()));
|
||||
if (Gdx.input.isKeyPressed(Keys.LEFT)) {
|
||||
rotateBy( 100.0f / home.getRadius());
|
||||
}
|
||||
if (Gdx.input.isKeyPressed(Keys.RIGHT)) {
|
||||
rotateBy(- 100.0f / home.getRadius());
|
||||
}
|
||||
|
||||
//this.bow.act(dt);
|
||||
setX(home.getX() + home.getRadius()*MathUtils.cosDeg(getRotation()));
|
||||
setY(home.getY() + home.getRadius()*MathUtils.sinDeg(getRotation()));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in a new issue