From 6b74d3ad7c3ddc9efd936537f45434f3bec68cec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Laure=CE=B7t?= Date: Tue, 13 Apr 2021 21:24:36 +0200 Subject: [PATCH] fix: changed a couple of methods --- core/src/sagittarius/model/Bow.java | 25 ++++++++--------------- core/src/sagittarius/model/Player.java | 19 ++++++----------- core/src/sagittarius/view/GameScreen.java | 13 ++++++------ 3 files changed, 20 insertions(+), 37 deletions(-) diff --git a/core/src/sagittarius/model/Bow.java b/core/src/sagittarius/model/Bow.java index e6f6de6..75b4b0a 100644 --- a/core/src/sagittarius/model/Bow.java +++ b/core/src/sagittarius/model/Bow.java @@ -35,7 +35,7 @@ public class Bow extends Actor { } // ---------- METHODs ---------- - + @Override public void act(float dt) { if (playing) { @@ -79,34 +79,25 @@ public class Bow extends Actor { power = MathUtils.clamp(aim.len(), 0, 1000); } - /** + /** * Generates an Arrow according to the Bow's attributes. - * + * * @return an Arrow. */ private Arrow getArrow() { return new Arrow(angle, power, shooter); } - /** - * Indiquer que c'est a son tour de jouer. + * Change the active state of the {@link Bow}. + * @param bool true or false */ - public void startPlaying() { - playing = true; + public void setPlaying(boolean bool) { + playing = bool; } - /** - * Indique que ce n'est plus son tour de jouer. - */ - public void stopPlaying() { - playing = false; - } - - - /** - * Savoir si il est entrain de jouer. + * @return the active state of the {@link Bow}. */ public boolean isPlaying() { return playing; diff --git a/core/src/sagittarius/model/Player.java b/core/src/sagittarius/model/Player.java index 4a57740..3460316 100644 --- a/core/src/sagittarius/model/Player.java +++ b/core/src/sagittarius/model/Player.java @@ -75,23 +75,16 @@ public class Player extends BaseActor { } /** - * Indiquer que c'est son tour de jouer. + * Change the active state of the {@link Player}. + * @param bool true or false */ - public void startPlaying() { - bow.startPlaying(); - playing = true; + public void setPlaying(boolean bool) { + bow.setPlaying(bool); + playing = bool; } /** - * Indique la fin de son tour de jeu. - */ - public void stopPlaying() { - bow.stopPlaying(); - playing = false; - } - - /** - * Savoir si il est entrain de jouer. + * @return the active state of the {@link Player}. */ public boolean isPlaying() { return playing; diff --git a/core/src/sagittarius/view/GameScreen.java b/core/src/sagittarius/view/GameScreen.java index 9d776e6..d683462 100644 --- a/core/src/sagittarius/view/GameScreen.java +++ b/core/src/sagittarius/view/GameScreen.java @@ -31,10 +31,10 @@ public class GameScreen extends BaseScreen { // planets & moons attractors = new Group(); - + Planet planet1 = new Planet(new Vector2(400, 400), 1000, 50, Color.BLUE); attractors.addActor(planet1); - + Planet planet2 = new Planet(new Vector2(1400, 700), 1000, 100, Color.ORANGE); attractors.addActor(planet2); @@ -54,7 +54,7 @@ public class GameScreen extends BaseScreen { mainStage.addActor(players); playerTurn = 0; - player1.startPlaying(); + player1.setPlaying(true); // arrows arrows = new Group(); @@ -81,16 +81,15 @@ public class GameScreen extends BaseScreen { Player actualPlayer = (Player) players.getChild(playerTurn); if (actualPlayer.isPlaying() && !actualPlayer.getBow().isPlaying()) { - actualPlayer.stopPlaying(); + actualPlayer.setPlaying(true); playerTurn++; playerTurn %= players.getChildren().size; actualPlayer = (Player) players.getChild(playerTurn); - actualPlayer.startPlaying(); + actualPlayer.setPlaying(false); } } - public void removePlayer(Player player) { int index = players.getChildren().indexOf(player, true); if (index < playerTurn) { @@ -101,7 +100,7 @@ public class GameScreen extends BaseScreen { players.removeActor(player); playerTurn %= players.getChildren().size; Player actualPlayer = (Player) players.getChild(playerTurn); - actualPlayer.startPlaying(); + actualPlayer.setPlaying(true); } else { players.removeActor(player); }