feat: bow cancel function

This commit is contained in:
Laureηt 2021-04-23 16:26:17 +02:00
parent ed9e805c88
commit ce3b1e265a
2 changed files with 6 additions and 2 deletions

View file

@ -2,6 +2,7 @@ package sagittarius.model;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.Input.Buttons;
import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.graphics.glutils.ShapeRenderer;
import com.badlogic.gdx.math.MathUtils;
import com.badlogic.gdx.math.Vector2;
@ -41,10 +42,12 @@ public class Bow extends Actor {
aim = this.anchor.cpy().sub(GameScreen.worldCursor);
angle = aim.angleDeg();
power = MathUtils.clamp(aim.len(), 0, 1000);
} else if (pressed) {
} else if (pressed && power > 50) {
pressed = false;
GameScreen.playerCurrent.setActive(false);
GameScreen.arrows.addActor(new Arrow(angle, power, GameScreen.playerCurrent));
} else {
pressed = false;
}
}
@ -52,6 +55,7 @@ public class Bow extends Actor {
public void drawDebug(ShapeRenderer shapes) {
super.drawDebug(shapes);
if (pressed) {
if (power > 50) shapes.setColor(Color.RED);
shapes.line(this.anchor, GameScreen.worldCursor);
if (aimAssist) {
float[] traj = Arrow.traj(angle, power, GameScreen.playerCurrent, 400, 0.05f);

View file

@ -112,7 +112,7 @@ public class GameScreen extends BaseScreen {
int index = players.getChildren().indexOf(player, true);
if (index < playerIndex) {
players.removeActor(player);
//playerIndex++; // ? keeping ?
playerIndex++;
playerIndex %= players.getChildren().size;
} else if (index == playerIndex) {
players.removeActor(player);