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