feat: Player can move around his Planet

This commit is contained in:
Laureηt 2021-04-05 23:31:06 +02:00
parent d92730db13
commit 9f58fa4a33
3 changed files with 23 additions and 9 deletions

View file

@ -78,12 +78,16 @@ class Arrow extends Entity {
}
void renderDebug(Batch batch, BitmapFont font) {
font.draw(batch, "TTL = " + this.TTL, this.position.x, this.position.y + font.getCapHeight()*5);
font.draw(batch, "pos = " + this.position, this.position.x, this.position.y + font.getCapHeight()*4);
font.draw(batch, "speed = " + this.velocity, this.position.x, this.position.y + font.getCapHeight()*3);
font.draw(batch, "accel = " + this.acceleration, this.position.x, this.position.y + font.getCapHeight()*2);
font.draw(batch, "force = " + this.force, this.position.x, this.position.y + font.getCapHeight()*1);
font.draw(batch, "angle = " + this.angle, this.position.x, this.position.y);
// TODO : dirty, do it in an other way
if (!hasLanded()) {
font.draw(batch, "TTL = " + this.TTL, this.position.x, this.position.y + font.getCapHeight()*5);
font.draw(batch, "pos = " + this.position, this.position.x, this.position.y + font.getCapHeight()*4);
font.draw(batch, "speed = " + this.velocity, this.position.x, this.position.y + font.getCapHeight()*3);
font.draw(batch, "accel = " + this.acceleration, this.position.x, this.position.y + font.getCapHeight()*2);
font.draw(batch, "force = " + this.force, this.position.x, this.position.y + font.getCapHeight()*1);
font.draw(batch, "angle = " + this.angle, this.position.x, this.position.y);
}
}
}

View file

@ -1,10 +1,14 @@
package bzh.fainsin.sagittarius;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.Input.Buttons;
import com.badlogic.gdx.Input.Keys;
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.MathUtils;
import com.badlogic.gdx.math.Vector2;
import com.badlogic.gdx.scenes.scene2d.ui.Button;
class Player extends Entity {
@ -40,12 +44,19 @@ class Player extends Entity {
void update(float deltaTime) {
// TODO : do eventListening instead of polling
// TODO : if player moving, add his speed to the arrow
if (Gdx.input.isKeyPressed(Keys.LEFT)) {
this.angle += 100.0f / home.getRadius();
} else if (Gdx.input.isKeyPressed(Keys.RIGHT)) {
this.angle -= 100.0f / home.getRadius();
}
computePosition();
bow.update(deltaTime);
// this.angle += 100.0f / home.getRadius(); // TODO : debug, remove later
}
void computePosition() {

View file

@ -39,7 +39,6 @@ public class SagittariusGame extends Game {
playerList.add( new Player(planetList.get(0)) );
arrowList = new ArrayList<Arrow>();
}
static void update(float deltaTime) {