fix: almost working, physics is still broken
This commit is contained in:
parent
6a95fe7d3a
commit
0301d8af71
|
@ -5,6 +5,7 @@ import java.util.ArrayList;
|
|||
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.Actor;
|
||||
|
||||
|
@ -34,10 +35,13 @@ public class Arrow extends Actor {
|
|||
*/
|
||||
Arrow(float angle, float power, Player shooter) {
|
||||
super();
|
||||
this.setPosition(shooter.getX(), shooter.getY());
|
||||
this.setPosition(shooter.getX() + shooter.getWidth() * MathUtils.cosDeg(shooter.getRotation()),
|
||||
shooter.getY() + shooter.getWidth() * MathUtils.sinDeg(shooter.getRotation()));
|
||||
this.velocity = new Vector2(power, 0).setAngleDeg(angle);
|
||||
this.acceleration = new Vector2();
|
||||
this.force = computeForce();
|
||||
this.setSize(100, 0);
|
||||
this.setOrigin(50, 0);
|
||||
}
|
||||
|
||||
// ---------- METHODs ----------
|
||||
|
@ -72,6 +76,10 @@ public class Arrow extends Actor {
|
|||
this.TTL -= dt;
|
||||
this.setRotation(this.velocity.angleDeg());
|
||||
|
||||
if (TTL <= 0) {
|
||||
GameScreen.arrows.removeActor(this);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -44,19 +44,20 @@ class Bow extends Actor {
|
|||
computeArrow();
|
||||
} else if (pressed) {
|
||||
// Sagittarius.arrowList.add(getArrow());
|
||||
GameScreen.arrows.addActor(getArrow());
|
||||
pressed = false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// /**
|
||||
// * Generates an Arrow according to the Bow's attributes.
|
||||
// *
|
||||
// * @return an Arrow.
|
||||
// */
|
||||
// private Arrow getArrow() {
|
||||
// return new Arrow(angle, power, shooter);
|
||||
// }
|
||||
/**
|
||||
* Generates an Arrow according to the Bow's attributes.
|
||||
*
|
||||
* @return an Arrow.
|
||||
*/
|
||||
private Arrow getArrow() {
|
||||
return new Arrow(angle, power, shooter);
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts the Bow's attributes to apply it
|
||||
|
|
|
@ -17,8 +17,9 @@ public class GameScreen extends BaseScreen {
|
|||
private static Vector3 unprojectedCursor;
|
||||
public static Vector2 worldCursor;
|
||||
|
||||
// planets = attractors for arrows
|
||||
public static Group planets; // TODO: move this in SagittariusGame ?
|
||||
// Groups // TODO: move this in SagittariusGame ?
|
||||
public static Group planets;
|
||||
public static Group arrows;
|
||||
|
||||
// ---------- METHODs ----------
|
||||
|
||||
|
@ -40,12 +41,14 @@ public class GameScreen extends BaseScreen {
|
|||
mainStage.addActor(planets);
|
||||
|
||||
// players
|
||||
|
||||
Player player1 = new Player(planet1, Color.WHITE);
|
||||
mainStage.addActor(player1);
|
||||
|
||||
// others
|
||||
// arrows
|
||||
arrows = new Group();
|
||||
mainStage.addActor(arrows);
|
||||
|
||||
// others
|
||||
FPS fpsCounter = new FPS();
|
||||
uiStage.addActor(fpsCounter);
|
||||
|
||||
|
|
Loading…
Reference in a new issue