diff --git a/client/src/main/java/fr/lnl/game/client/view/Cell.java b/client/src/main/java/fr/lnl/game/client/view/Cell.java index 2c27805..7cb48e5 100644 --- a/client/src/main/java/fr/lnl/game/client/view/Cell.java +++ b/client/src/main/java/fr/lnl/game/client/view/Cell.java @@ -5,10 +5,11 @@ import fr.lnl.game.server.games.action.Shot; import fr.lnl.game.server.games.grid.elements.Bomb; import fr.lnl.game.server.games.grid.elements.EnergyBall; import fr.lnl.game.server.games.grid.elements.Mine; +import fr.lnl.game.server.games.grid.elements.Wall; import fr.lnl.game.server.games.player.Player; import javafx.scene.image.Image; import javafx.scene.image.ImageView; -import javafx.scene.layout.StackPane; +import javafx.scene.layout.*; import javafx.scene.paint.Color; import javafx.scene.shape.Rectangle; @@ -18,13 +19,20 @@ import javafx.scene.shape.Rectangle; */ public class Cell extends Rectangle { + //Images libres de droit : + //https://www.minecraftforum.net/forums/mapping-and-modding-java-edition/resource-packs/1242533-pixel-perfection-now-with-polar-bears-1-11 + //https://www.stocklib.fr/media-134367689/pixel-game-icons-vector-isolated-bombs-with-fire-graphics-of-retro-gaming-flat-style-of-weapon-with-flames-destruction-and-danger-explosive-substance.html?keyword=bomb%20pixel + private static final Image PLAYER_IMAGE = new Image("player.png"); private static final Image PLAYER_SHIELD_IMAGE = new Image("player_shield.png"); private static final Image PLAYER_SHOT_IMAGE = new Image("player_shot.png"); private static final Image ENERGY_BALL_IMAGE = new Image("energyBall.png"); private static final Image BOMB_IMAGE = new Image("bomb.png"); private static final Image MINE_IMAGE = new Image("mine.png"); - private static final Image WALL_IMAGE = new Image("wall.jpg"); + private static final Image WALL_IMAGE = new Image("wall.png"); + private static final Image BACKGROUND_IMAGE = new Image("background.png"); + private static final BackgroundImage BG = new BackgroundImage(BACKGROUND_IMAGE,BackgroundRepeat.NO_REPEAT,BackgroundRepeat.NO_REPEAT,BackgroundPosition.DEFAULT, + BackgroundSize.DEFAULT); public Cell(int x, int y){ setWidth(Window.cellSize); @@ -39,7 +47,9 @@ public class Cell extends Rectangle { public static StackPane setImageObject(Object object, Game game){ StackPane sp = new StackPane(); Image in; + BackgroundImage bg = BG; if(object instanceof Player){ + bg = null; if(object.equals(game.getCurrentPlayer()) && game.getSelectedAction() instanceof Shot){ in = PLAYER_SHOT_IMAGE; } @@ -55,14 +65,20 @@ public class Cell extends Rectangle { in = BOMB_IMAGE; } else if(object instanceof Mine){ in = MINE_IMAGE; - } else{ + } + else if(object instanceof Wall){ in = WALL_IMAGE; + bg = null; + } + else{ + in = null; } ImageView iv = new ImageView(in); iv.setFitHeight(Window.cellSize); iv.setFitWidth(Window.cellSize); sp.getChildren().add(iv); + sp.setBackground(new Background(bg)); return sp; } diff --git a/client/src/main/java/fr/lnl/game/client/view/Window.java b/client/src/main/java/fr/lnl/game/client/view/Window.java index 00ce2e2..5a19a77 100644 --- a/client/src/main/java/fr/lnl/game/client/view/Window.java +++ b/client/src/main/java/fr/lnl/game/client/view/Window.java @@ -11,12 +11,12 @@ import fr.lnl.game.server.games.grid.elements.*; import fr.lnl.game.server.games.player.Player; import fr.lnl.game.server.utils.Pair; import fr.lnl.game.server.utils.Point; +import javafx.geometry.Insets; import javafx.scene.Parent; import javafx.scene.Scene; import javafx.scene.control.Alert; import javafx.scene.control.Button; -import javafx.scene.layout.Pane; -import javafx.scene.layout.StackPane; +import javafx.scene.layout.*; import javafx.scene.paint.Color; import javafx.scene.shape.Rectangle; import javafx.scene.text.Text; @@ -31,6 +31,8 @@ public class Window extends AbstractView { public static final int cellSize = 40; public static final int width = 500; public static final int height = 160; + private static final Color dark = Color.valueOf("1F1F1F"); + private static final Background bg = new Background(new BackgroundFill(dark, CornerRadii.EMPTY, Insets.EMPTY)); private final Stage stage; @@ -90,14 +92,20 @@ public class Window extends AbstractView { if (value.getB() instanceof Wall || value.getB() instanceof EnergyBall) { addToPrincipalPanel(value.getB(), principalPane, i, j); } - if(value.getB() instanceof Explosive){ + else if(value.getB() instanceof Explosive){ if(((Explosive) value.getB()).getPlayer().equals(player)){ addToPrincipalPanel(value.getB(), principalPane, i, j); } + else{ + addToPrincipalPanel(null,principalPane, i, j); + } } - if (value.getA() != null) { + else if (value.getA() != null) { addToPrincipalPanel(value.getA(), principalPane, i, j); } + else{ + addToPrincipalPanel(null,principalPane, i, j); + } } } putStatePlayerPane(principalPane); @@ -109,6 +117,7 @@ public class Window extends AbstractView { buttonNext .setStyle("-fx-background-color: #a96806;"); buttonNext .setTextFill(javafx.scene.paint.Color.WHITE); principalPane.getChildren().add(buttonNext); + principalPane.setBackground(bg); return principalPane; } @@ -143,9 +152,9 @@ public class Window extends AbstractView { r.setWidth(500); r.setHeight(90); if(game.getPlayers().get(playerNumber).getEnergy() <= 0){ - r.setFill(Color.RED); + r.setFill(Color.valueOf("A54747")); }else{ - r.setFill(Color.GREEN); + r.setFill(Color.valueOf("62B262")); } r.setStrokeWidth(1); r.setStroke(Color.BLACK); @@ -165,12 +174,13 @@ public class Window extends AbstractView { String s = player + " : " + (player.getId()+1) + "\n" + "Vient de jouer : " + action + "\n"; Text t = new Text(s); + t.setFill(Color.WHITE); Rectangle r = new Rectangle(); r.setWidth(478); r.setHeight(165); r.setStrokeWidth(1); r.setStroke(Color.BLACK); - r.setFill(Color.WHITE); + r.setFill(dark); subSp.getChildren().addAll(r,t); return subSp; } diff --git a/client/src/main/resources/background.png b/client/src/main/resources/background.png new file mode 100644 index 0000000..c86661b Binary files /dev/null and b/client/src/main/resources/background.png differ diff --git a/client/src/main/resources/bomb.png b/client/src/main/resources/bomb.png index 012c1a2..cc72c9c 100644 Binary files a/client/src/main/resources/bomb.png and b/client/src/main/resources/bomb.png differ diff --git a/client/src/main/resources/energyBall.png b/client/src/main/resources/energyBall.png index 3dd424a..819b9d3 100644 Binary files a/client/src/main/resources/energyBall.png and b/client/src/main/resources/energyBall.png differ diff --git a/client/src/main/resources/mine.png b/client/src/main/resources/mine.png index c23e00b..13f60a1 100644 Binary files a/client/src/main/resources/mine.png and b/client/src/main/resources/mine.png differ diff --git a/client/src/main/resources/wall.jpg b/client/src/main/resources/wall.jpg deleted file mode 100644 index 8801b4f..0000000 Binary files a/client/src/main/resources/wall.jpg and /dev/null differ diff --git a/client/src/main/resources/wall.png b/client/src/main/resources/wall.png new file mode 100644 index 0000000..5727d95 Binary files /dev/null and b/client/src/main/resources/wall.png differ