From ce3b1e265ab9ef3692e34caab9784e249f3ad5a6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Laure=CE=B7t?= Date: Fri, 23 Apr 2021 16:26:17 +0200 Subject: [PATCH] feat: bow cancel function --- core/src/sagittarius/model/Bow.java | 6 +++++- core/src/sagittarius/view/GameScreen.java | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/core/src/sagittarius/model/Bow.java b/core/src/sagittarius/model/Bow.java index 49259ed..2f52ebf 100644 --- a/core/src/sagittarius/model/Bow.java +++ b/core/src/sagittarius/model/Bow.java @@ -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); diff --git a/core/src/sagittarius/view/GameScreen.java b/core/src/sagittarius/view/GameScreen.java index f657452..ebf9a7c 100644 --- a/core/src/sagittarius/view/GameScreen.java +++ b/core/src/sagittarius/view/GameScreen.java @@ -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);