feat: used Entities instead of Actors

This commit is contained in:
Laureηt 2021-04-22 17:43:41 +02:00
parent 6cd727c09d
commit eb0a6a6253
8 changed files with 19 additions and 26 deletions

View file

@ -9,9 +9,7 @@ import com.badlogic.gdx.scenes.scene2d.Actor;
import sagittarius.SagittariusGame;
import sagittarius.view.GameScreen;
public class Arrow extends BaseActor {
public static final float initTTL = 20;
public class Arrow extends EntityQuad {
// ---------- ATTRIBUTEs ----------
@ -19,7 +17,7 @@ public class Arrow extends BaseActor {
private Vector2 acceleration;
private Vector2 force;
private float TTL = initTTL;
private float TTL = 20;
private boolean landed;
private Planet crash;
@ -35,8 +33,7 @@ public class Arrow extends BaseActor {
* @param shooter Bow's shooter.
*/
Arrow(float angle, float power, Player shooter) {
super();
this.setPosition(shooter.getX(), shooter.getY());
super(0, 1, shooter.getColor(), shooter.getPosition());
this.velocity = new Vector2(power, 0).setAngleDeg(angle);
this.acceleration = new Vector2();
this.setOrigin(80, 2);
@ -49,7 +46,7 @@ public class Arrow extends BaseActor {
@Override
public void act(float dt) {
super.act(dt);
if (!landed) {
integrationVerlet(dt);
this.TTL -= dt;

View file

@ -23,8 +23,8 @@ public abstract class BaseActor extends Actor {
// ---------- METHODs ----------
@Override
public void act(float delta) {
super.act(delta);
public void act(float dt) {
super.act(dt);
hitbox.setVertices(test());
}

View file

@ -34,7 +34,7 @@ public class Bow extends Actor {
@Override
public void act(float dt) {
super.act(dt);
this.shooter = GameScreen.actualPlayer;
// TODO: probably can do better with an eventListener

View file

@ -112,21 +112,20 @@ public abstract class Entity extends Actor {
protected abstract float[] getHitbox();
@Override
public void act(float delta) {
super.act(delta);
public void act(float dt) {
super.act(dt);
hitbox.setVertices(getHitbox());
}
@Override
public void draw(Batch batch, float parentAlpha) {
super.draw(batch, parentAlpha);
//if (getDebug())
fontDebug.draw(batch, getInfo(), getX(), getY());
if (getDebug()) fontDebug.draw(batch, getInfo(), getX(), getY());
}
@Override
protected void drawDebugBounds(ShapeRenderer shapes) {
//if (!getDebug()) return;
if (!getDebug()) return;
shapes.set(ShapeType.Line);
if (getStage() != null) shapes.setColor(this.getColor());
shapes.polygon(hitbox.getVertices());

View file

@ -17,8 +17,8 @@ public class FPS extends BaseActor {
}
@Override
public void act(float delta) {
super.act(delta);
public void act(float dt) {
super.act(dt);
frameRate = Gdx.graphics.getFramesPerSecond();
}

View file

@ -7,8 +7,8 @@ public class MouseInfo extends BaseActor {
// ---------- METHODs ----------
@Override
public void act(float delta) {
super.act(delta);
public void act(float dt) {
super.act(dt);
setX(GameScreen.worldCursor.x); // use direct method
setY(GameScreen.worldCursor.y);
}

View file

@ -6,7 +6,7 @@ import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.graphics.glutils.ShapeRenderer;
import com.badlogic.gdx.math.MathUtils;
public class Player extends BaseActor {
public class Player extends EntityQuad {
// ---------- ATTRIBUTEs ----------
@ -16,14 +16,11 @@ public class Player extends BaseActor {
// ---------- CONSTRUCTORs ----------
public Player(Planet home, Color color) {
super();
super(MathUtils.random(360), 0, color, home.getPosition());
this.setRotation(angle-90);
this.setSize(50, 100);
this.setOrigin(getWidth()/2, getHeight()/2);
this.setColor(color);
this.angle = MathUtils.random(360);
this.setRotation(angle-90);
this.home = home;
}

View file

@ -48,7 +48,7 @@ public class GameScreen extends BaseScreen {
// players
players = new Group();
Player player1 = new Player(planet1, Color.WHITE);
Player player1 = new Player(planet1, Color.RED);
players.addActor(player1);
Player player2 = new Player(planet2, Color.WHITE);