fix: disabled pixmapping for arrow trajectory prediction

This commit is contained in:
Laureηt 2021-05-12 21:54:34 +02:00
parent 61924b85b6
commit e047063e7e
2 changed files with 23 additions and 21 deletions

View file

@ -41,7 +41,7 @@ public class Arrow extends EntityQuad {
* @param power power given to the Arrow by the Bow.
* @param shooter Bow's shooter.
*/
Arrow(float angle, float power, Player shooter) {
Arrow(float angle, float power, Player shooter, boolean preview) {
super(0, 1, shooter.getColor(), shooter.getPosition());
this.velocity = new Vector2(power, 0).setAngleDeg(angle);
this.acceleration = new Vector2();
@ -50,9 +50,9 @@ public class Arrow extends EntityQuad {
this.force = computeForce();
this.landed = false;
if (!preview) {
Random random = new Random();
Pixmap pm = new Pixmap(new FileHandle("core/assets/arrow" + (random.nextInt(2) + 1) + ".png"));
pm.setBlending(Pixmap.Blending.None);
for (int x = 0; x < pm.getWidth(); x++) {
for (int y = 0; y < pm.getHeight(); y++) {
@ -72,6 +72,8 @@ public class Arrow extends EntityQuad {
texture = new Texture(pm);
}
}
// ---------- METHODs ----------
@Override
@ -215,7 +217,7 @@ public class Arrow extends EntityQuad {
*/
static float[] traj(float angle, float power, Player shooter, int iterations, float timeStep) {
ArrayList<Float> path = new ArrayList<Float>();
Arrow dummyArrow = new Arrow(angle, power, shooter);
Arrow dummyArrow = new Arrow(angle, power, shooter, true);
for (int i = 0; i < iterations; i++) {
dummyArrow.integrationVerlet(timeStep);
path.add(dummyArrow.getX());

View file

@ -45,7 +45,7 @@ public class Bow extends Actor {
} else if (pressed && power > 50) {
pressed = false;
GameScreen.playerCurrent.setActive(false);
Arrow arrowShot = new Arrow(angle, power, GameScreen.playerCurrent);
Arrow arrowShot = new Arrow(angle, power, GameScreen.playerCurrent, false);
GameScreen.setFocus(arrowShot); // do not use constructor 2 times
GameScreen.arrows.addActor(arrowShot);
} else {