Merge branch 'master' into conflit-3

This commit is contained in:
Quentin Legot 2021-12-09 12:51:10 +01:00 committed by GitHub
commit aacbd65b56
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 40 additions and 10 deletions

View File

@ -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.Bomb;
import fr.lnl.game.server.games.grid.elements.EnergyBall; 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.Mine;
import fr.lnl.game.server.games.grid.elements.Wall;
import fr.lnl.game.server.games.player.Player; import fr.lnl.game.server.games.player.Player;
import javafx.scene.image.Image; import javafx.scene.image.Image;
import javafx.scene.image.ImageView; import javafx.scene.image.ImageView;
import javafx.scene.layout.StackPane; import javafx.scene.layout.*;
import javafx.scene.paint.Color; import javafx.scene.paint.Color;
import javafx.scene.shape.Rectangle; import javafx.scene.shape.Rectangle;
@ -18,13 +19,20 @@ import javafx.scene.shape.Rectangle;
*/ */
public class Cell extends 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_IMAGE = new Image("player.png");
private static final Image PLAYER_SHIELD_IMAGE = new Image("player_shield.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 PLAYER_SHOT_IMAGE = new Image("player_shot.png");
private static final Image ENERGY_BALL_IMAGE = new Image("energyBall.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 BOMB_IMAGE = new Image("bomb.png");
private static final Image MINE_IMAGE = new Image("mine.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){ public Cell(int x, int y){
setWidth(Window.cellSize); setWidth(Window.cellSize);
@ -39,7 +47,9 @@ public class Cell extends Rectangle {
public static StackPane setImageObject(Object object, Game game){ public static StackPane setImageObject(Object object, Game game){
StackPane sp = new StackPane(); StackPane sp = new StackPane();
Image in; Image in;
BackgroundImage bg = BG;
if(object instanceof Player){ if(object instanceof Player){
bg = null;
if(object.equals(game.getCurrentPlayer()) && game.getSelectedAction() instanceof Shot){ if(object.equals(game.getCurrentPlayer()) && game.getSelectedAction() instanceof Shot){
in = PLAYER_SHOT_IMAGE; in = PLAYER_SHOT_IMAGE;
} }
@ -55,15 +65,24 @@ public class Cell extends Rectangle {
in = BOMB_IMAGE; in = BOMB_IMAGE;
} else if(object instanceof Mine){ } else if(object instanceof Mine){
in = MINE_IMAGE; in = MINE_IMAGE;
} else{ }
else if(object instanceof Wall){
in = WALL_IMAGE; in = WALL_IMAGE;
bg = null;
}
else{
in = null;
} }
ImageView iv = new ImageView(in); ImageView iv = new ImageView(in);
iv.setFitHeight(Window.cellSize); iv.setFitHeight(Window.cellSize);
iv.setFitWidth(Window.cellSize); iv.setFitWidth(Window.cellSize);
sp.getChildren().add(iv); sp.getChildren().add(iv);
sp.setBackground(new Background(bg));
return sp; return sp;
} }
public static Image getPlayerImage() {
return PLAYER_IMAGE;
}
} }

View File

@ -15,12 +15,12 @@ import fr.lnl.game.server.utils.Pair;
import fr.lnl.game.server.utils.Point; import fr.lnl.game.server.utils.Point;
import javafx.event.ActionEvent; import javafx.event.ActionEvent;
import javafx.event.EventHandler; import javafx.event.EventHandler;
import javafx.geometry.Insets;
import javafx.scene.Parent; import javafx.scene.Parent;
import javafx.scene.Scene; import javafx.scene.Scene;
import javafx.scene.control.Alert; import javafx.scene.control.Alert;
import javafx.scene.control.Button; import javafx.scene.control.Button;
import javafx.scene.layout.Pane; import javafx.scene.layout.*;
import javafx.scene.layout.StackPane;
import javafx.scene.paint.Color; import javafx.scene.paint.Color;
import javafx.scene.shape.Rectangle; import javafx.scene.shape.Rectangle;
import javafx.scene.text.Text; import javafx.scene.text.Text;
@ -35,6 +35,8 @@ public class Window extends AbstractView {
public static final int cellSize = 40; public static final int cellSize = 40;
public static final int width = 500; public static final int width = 500;
public static final int height = 160; 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; private final Stage stage;
@ -52,6 +54,7 @@ public class Window extends AbstractView {
Scene scene = new Scene(createContent()); Scene scene = new Scene(createContent());
stage.setScene(scene); stage.setScene(scene);
stage.setTitle("Game"); stage.setTitle("Game");
stage.getIcons().add(Cell.getPlayerImage());
stage.setResizable(false); stage.setResizable(false);
stage.sizeToScene(); stage.sizeToScene();
stage.show(); stage.show();
@ -124,14 +127,20 @@ public class Window extends AbstractView {
if (value.getB() instanceof Wall || value.getB() instanceof EnergyBall) { if (value.getB() instanceof Wall || value.getB() instanceof EnergyBall) {
addToPrincipalPanel(value.getB(), principalPane, i, j); addToPrincipalPanel(value.getB(), principalPane, i, j);
} }
if(value.getB() instanceof Explosive){ else if(value.getB() instanceof Explosive){
if(((Explosive) value.getB()).getPlayer().equals(player)){ if(((Explosive) value.getB()).getPlayer().equals(player)){
addToPrincipalPanel(value.getB(), principalPane, i, j); 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); addToPrincipalPanel(value.getA(), principalPane, i, j);
} }
else{
addToPrincipalPanel(null,principalPane, i, j);
}
} }
} }
putStatePlayerPane(principalPane); putStatePlayerPane(principalPane);
@ -150,6 +159,7 @@ public class Window extends AbstractView {
} }
principalPane.getChildren().add(buttonPane); principalPane.getChildren().add(buttonPane);
principalPane.setBackground(bg);
return principalPane; return principalPane;
} }
@ -184,9 +194,9 @@ public class Window extends AbstractView {
r.setWidth(500); r.setWidth(500);
r.setHeight(90); r.setHeight(90);
if(game.getPlayers().get(playerNumber).getEnergy() <= 0){ if(game.getPlayers().get(playerNumber).getEnergy() <= 0){
r.setFill(Color.RED); r.setFill(Color.valueOf("A54747"));
}else{ }else{
r.setFill(Color.GREEN); r.setFill(Color.valueOf("62B262"));
} }
r.setStrokeWidth(1); r.setStrokeWidth(1);
r.setStroke(Color.BLACK); r.setStroke(Color.BLACK);
@ -210,12 +220,13 @@ public class Window extends AbstractView {
} }
Text t = new Text(s); Text t = new Text(s);
t.setFill(Color.WHITE);
Rectangle r = new Rectangle(); Rectangle r = new Rectangle();
r.setWidth(478); r.setWidth(478);
r.setHeight(165); r.setHeight(165);
r.setStrokeWidth(1); r.setStrokeWidth(1);
r.setStroke(Color.BLACK); r.setStroke(Color.BLACK);
r.setFill(Color.WHITE); r.setFill(dark);
subSp.getChildren().addAll(r,t); subSp.getChildren().addAll(r,t);
return subSp; return subSp;
} }

Binary file not shown.

After

Width:  |  Height:  |  Size: 334 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.5 KiB

After

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 12 KiB

After

Width:  |  Height:  |  Size: 285 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.1 KiB

After

Width:  |  Height:  |  Size: 525 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 56 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 360 B