From a2270d5de04833cb3e6b6a7b589788af5b6a80fc Mon Sep 17 00:00:00 2001 From: Valentin Valentin <21901740@etu.unicaen.fr> Date: Fri, 5 Nov 2021 15:42:06 +0100 Subject: [PATCH] =?UTF-8?q?Ajout=20de=20la=20classe=20Cell=20et=20GUI,=20d?= =?UTF-8?q?=C3=A9but=20d'impl=C3=A9mentation=20de=20certaines=20de=20leurs?= =?UTF-8?q?=20m=C3=A9thodes.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/fr/lnl/game/client/view/Cell.java | 64 +++++++++++++++++++ .../java/fr/lnl/game/client/view/GUI.java | 52 +++++++++++++++ .../java/fr/lnl/game/client/view/Window.java | 1 + 3 files changed, 117 insertions(+) create mode 100644 client/src/main/java/fr/lnl/game/client/view/Cell.java create mode 100644 client/src/main/java/fr/lnl/game/client/view/GUI.java 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 new file mode 100644 index 0000000..c915462 --- /dev/null +++ b/client/src/main/java/fr/lnl/game/client/view/Cell.java @@ -0,0 +1,64 @@ +package fr.lnl.game.client.view; + +import fr.lnl.game.server.games.grid.Bomb; +import fr.lnl.game.server.games.grid.EnergyBall; +import fr.lnl.game.server.games.grid.Mine; +import fr.lnl.game.server.games.grid.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.paint.Color; +import javafx.scene.shape.Rectangle; + + + +/*classe qui a pour but de générer chaque case de la grid et de vérifier les entités présentes dessus +(Mur,Joueur,Energie,bombe,etc..) +*/ + +public class Cell extends Rectangle { + + //NON-ETABLIE + public Cell(int x, int y){ + setWidth(GUI.cellSize); + setHeight(GUI.cellSize); + relocate(x,y); + setFill(Color.valueOf("#ffffff")); + setStroke(Color.DARKGRAY); + } + + + //NON-TEST + public static StackPane setImageObject(Object object){ + //voir pour rajouter un répertoire ou stocker les images; + Image image; + StackPane sp = new StackPane(); + //remplacer après par le switch dès que on aura implémenter les interfaces + + if(object instanceof Player){ + //image = new Image(); + } + if(object instanceof EnergyBall){ + //image = new Image(); + } + if(object instanceof Bomb){ + //image = new Image(); + } + if(object instanceof Mine){ + //image = new Image(); + } + if(object instanceof Wall){ + //image = new Image(); + } + + /* + ImageView iv = new ImageView(image); + iv.setFitHeight(40); + iv.setFitWidth(40); + sp.getChilldren().add(iv); + */ + return sp; + } + +} diff --git a/client/src/main/java/fr/lnl/game/client/view/GUI.java b/client/src/main/java/fr/lnl/game/client/view/GUI.java new file mode 100644 index 0000000..e72a922 --- /dev/null +++ b/client/src/main/java/fr/lnl/game/client/view/GUI.java @@ -0,0 +1,52 @@ +package fr.lnl.game.client.view; + + +import fr.lnl.game.server.games.grid.Box; +import fr.lnl.game.server.games.grid.Grid; +import fr.lnl.game.server.games.player.Player; +import fr.lnl.game.server.utils.Pair; +import fr.lnl.game.server.utils.Point; +import javafx.scene.Parent; +import javafx.scene.Scene; +import javafx.scene.layout.Pane; +import javafx.stage.Modality; +import javafx.stage.Stage; + +import java.util.HashMap; + +public class GUI { + + //à revoir pour respecter MVC + HashMap> board; + Stage stage; + Scene scene; + Grid grid; + String text =""; + + + //temporaire + public static final int cellSize = 40; + public static final int width = 24; + public static final int height = 16; + + public GUI(){ + stage = new Stage(); + stage.initModality(Modality.APPLICATION_MODAL); + //ce n'est pas à la vue de gérer ça donc à voir + //grid = getGrid(); + scene = new Scene(createContent()); + stage.setScene(scene); + stage.setTitle("Game"); + stage.setResizable(false); + stage.show(); + } + + private Parent createContent() { + Pane principalPane = new Pane(); + + + return principalPane; + } + + +} 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 f9204d0..aa64a8e 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 @@ -31,5 +31,6 @@ public class Window extends AbstractView { Scene scene = new Scene(grid, 640, 480); stage.setScene(scene); stage.show(); + } }