feat: bow cancel function
This commit is contained in:
parent
ed9e805c88
commit
ce3b1e265a
|
@ -2,6 +2,7 @@ package sagittarius.model;
|
||||||
|
|
||||||
import com.badlogic.gdx.Gdx;
|
import com.badlogic.gdx.Gdx;
|
||||||
import com.badlogic.gdx.Input.Buttons;
|
import com.badlogic.gdx.Input.Buttons;
|
||||||
|
import com.badlogic.gdx.graphics.Color;
|
||||||
import com.badlogic.gdx.graphics.glutils.ShapeRenderer;
|
import com.badlogic.gdx.graphics.glutils.ShapeRenderer;
|
||||||
import com.badlogic.gdx.math.MathUtils;
|
import com.badlogic.gdx.math.MathUtils;
|
||||||
import com.badlogic.gdx.math.Vector2;
|
import com.badlogic.gdx.math.Vector2;
|
||||||
|
@ -41,10 +42,12 @@ public class Bow extends Actor {
|
||||||
aim = this.anchor.cpy().sub(GameScreen.worldCursor);
|
aim = this.anchor.cpy().sub(GameScreen.worldCursor);
|
||||||
angle = aim.angleDeg();
|
angle = aim.angleDeg();
|
||||||
power = MathUtils.clamp(aim.len(), 0, 1000);
|
power = MathUtils.clamp(aim.len(), 0, 1000);
|
||||||
} else if (pressed) {
|
} else if (pressed && power > 50) {
|
||||||
pressed = false;
|
pressed = false;
|
||||||
GameScreen.playerCurrent.setActive(false);
|
GameScreen.playerCurrent.setActive(false);
|
||||||
GameScreen.arrows.addActor(new Arrow(angle, power, GameScreen.playerCurrent));
|
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) {
|
public void drawDebug(ShapeRenderer shapes) {
|
||||||
super.drawDebug(shapes);
|
super.drawDebug(shapes);
|
||||||
if (pressed) {
|
if (pressed) {
|
||||||
|
if (power > 50) shapes.setColor(Color.RED);
|
||||||
shapes.line(this.anchor, GameScreen.worldCursor);
|
shapes.line(this.anchor, GameScreen.worldCursor);
|
||||||
if (aimAssist) {
|
if (aimAssist) {
|
||||||
float[] traj = Arrow.traj(angle, power, GameScreen.playerCurrent, 400, 0.05f);
|
float[] traj = Arrow.traj(angle, power, GameScreen.playerCurrent, 400, 0.05f);
|
||||||
|
|
|
@ -112,7 +112,7 @@ public class GameScreen extends BaseScreen {
|
||||||
int index = players.getChildren().indexOf(player, true);
|
int index = players.getChildren().indexOf(player, true);
|
||||||
if (index < playerIndex) {
|
if (index < playerIndex) {
|
||||||
players.removeActor(player);
|
players.removeActor(player);
|
||||||
//playerIndex++; // ? keeping ?
|
playerIndex++;
|
||||||
playerIndex %= players.getChildren().size;
|
playerIndex %= players.getChildren().size;
|
||||||
} else if (index == playerIndex) {
|
} else if (index == playerIndex) {
|
||||||
players.removeActor(player);
|
players.removeActor(player);
|
||||||
|
|
Loading…
Reference in a new issue