revert 6232e6f93e
revert Merge branch 'main' of https://grond.iut-fbleau.fr/stiti/SAE31_2024
This commit is contained in:
@@ -1,15 +1,12 @@
|
||||
public class GameController {
|
||||
private GameView view;
|
||||
private Board board;
|
||||
|
||||
// Constructeur qui prend GameView comme argument
|
||||
public GameController(GameView view) {
|
||||
this.view = view;
|
||||
this.board = view.getBoard(); // Associer le Board à partir de la vue
|
||||
}
|
||||
|
||||
// Méthode pour démarrer le jeu
|
||||
public void startGame() {
|
||||
view.setVisible(true); // Afficher la fenêtre
|
||||
System.out.println("Bienvenue dans Dorfromantik simplifié !");
|
||||
view.showTile();
|
||||
}
|
||||
}
|
||||
|
@@ -1,8 +1,15 @@
|
||||
public class Main {
|
||||
public static void main(String[] args) {
|
||||
Board board = new Board();
|
||||
GameView view = new GameView(board);
|
||||
GameController controller = new GameController(view); // Passe la vue au contrôleur
|
||||
controller.startGame(); // Démarre le jeu
|
||||
// Exemple : création d'une tuile avec deux terrains
|
||||
Tile tile = new Tile(Terrain.MER, Terrain.FORET, 1);
|
||||
|
||||
// Vue graphique
|
||||
GameView view = new GameView(tile);
|
||||
|
||||
// Contrôleur
|
||||
GameController controller = new GameController(view);
|
||||
|
||||
// Démarrer le jeu
|
||||
controller.startGame();
|
||||
}
|
||||
}
|
||||
|
Binary file not shown.
@@ -3,24 +3,30 @@ import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class Board {
|
||||
private final Map<Point, Tile> tiles;
|
||||
private Map<Point, Tile> tiles;
|
||||
|
||||
public Board() {
|
||||
this.tiles = new HashMap<>();
|
||||
tiles = new HashMap<>();
|
||||
}
|
||||
|
||||
// Vérifie si la position est déjà occupée
|
||||
public boolean isPositionOccupied(Point position) {
|
||||
return tiles.containsKey(position);
|
||||
}
|
||||
|
||||
// Ajoute une tuile à une position donnée
|
||||
public void addTile(Point position, Tile tile) {
|
||||
if (!isPositionOccupied(position)) {
|
||||
tiles.put(position, tile);
|
||||
}
|
||||
}
|
||||
|
||||
// Récupère la tuile à une position donnée
|
||||
public Tile getTile(Point position) {
|
||||
return tiles.get(position);
|
||||
}
|
||||
|
||||
// Récupère toutes les tuiles
|
||||
public Map<Point, Tile> getTiles() {
|
||||
return tiles;
|
||||
}
|
||||
|
Binary file not shown.
@@ -1,13 +1,11 @@
|
||||
public class GameController {
|
||||
private final Board board;
|
||||
private final GameView view;
|
||||
private GameView view;
|
||||
|
||||
public GameController(GameView view) {
|
||||
this.board = new Board();
|
||||
this.view = view;
|
||||
}
|
||||
|
||||
public void startGame() {
|
||||
view.setVisible(true);
|
||||
view.showBoard();
|
||||
}
|
||||
}
|
||||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -4,10 +4,12 @@ import java.awt.event.MouseAdapter;
|
||||
import java.awt.event.MouseEvent;
|
||||
|
||||
public class GameView extends JFrame {
|
||||
private final Board board;
|
||||
private final int hexRadius = 60;
|
||||
private final int hexWidth = (int) (Math.sqrt(3) * hexRadius); // Largeur d'un hexagone
|
||||
private final int hexHeight = 2 * hexRadius; // Hauteur d'un hexagone
|
||||
private Board board;
|
||||
private int hexRadius = 30; // Rayon du grand hexagone
|
||||
|
||||
// Dimensions calculées des hexagones
|
||||
private int hexWidth = (int) (1.5 * hexRadius); // Largeur de l'hexagone
|
||||
private int hexHeight = (int) (Math.sqrt(3) * hexRadius); // Hauteur de l'hexagone
|
||||
|
||||
public GameView(Board board) {
|
||||
this.board = board;
|
||||
@@ -16,79 +18,118 @@ public class GameView extends JFrame {
|
||||
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
||||
setLocationRelativeTo(null);
|
||||
|
||||
// Gestion des clics de souris pour placer une tuile
|
||||
addMouseListener(new MouseAdapter() {
|
||||
@Override
|
||||
public void mouseClicked(MouseEvent e) {
|
||||
handleMouseClick(e.getPoint());
|
||||
handleMouseClick(e.getX(), e.getY());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void handleMouseClick(Point clickPoint) {
|
||||
// Calcul de la position en coordonnées hexagonales
|
||||
Point hexPosition = calculateHexCoordinates(clickPoint);
|
||||
|
||||
// Vérifie si la position est libre
|
||||
if (!board.isPositionOccupied(hexPosition)) {
|
||||
Tile newTile = new Tile(Terrain.FORET); // Exemple : tuile de forêt
|
||||
board.addTile(hexPosition, newTile);
|
||||
public void showBoard() {
|
||||
setVisible(true);
|
||||
repaint();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void paint(Graphics g) {
|
||||
super.paint(g);
|
||||
Graphics2D g2d = (Graphics2D) g;
|
||||
|
||||
// Dessiner toutes les tuiles placées
|
||||
// Dessiner toutes les tuiles du plateau
|
||||
for (Point position : board.getTiles().keySet()) {
|
||||
Tile tile = board.getTile(position);
|
||||
int x = calculateScreenX(position);
|
||||
int y = calculateScreenY(position);
|
||||
drawLargeHexagon(g2d, x, y, tile);
|
||||
drawLargeHexagon(g2d, position.x, position.y, tile);
|
||||
}
|
||||
}
|
||||
|
||||
private void drawLargeHexagon(Graphics2D g2d, int x, int y, Tile tile) {
|
||||
Polygon hexagon = new Polygon();
|
||||
private void drawLargeHexagon(Graphics2D g2d, int centerX, int centerY, Tile tile) {
|
||||
// Couleurs des triangles
|
||||
Color color1 = getColorForTerrain(tile.getTerrain());
|
||||
Color color2 = color1.darker(); // Variante plus sombre pour contraste
|
||||
|
||||
// Dessiner les 6 triangles pour former l'hexagone
|
||||
for (int i = 0; i < 6; i++) {
|
||||
double angle = Math.toRadians(60 * i);
|
||||
int px = x + (int) (Math.cos(angle) * hexRadius);
|
||||
int py = y + (int) (Math.sin(angle) * hexRadius);
|
||||
hexagon.addPoint(px, py);
|
||||
// Dessiner chaque triangle équilatéral avec sa couleur associée
|
||||
drawTriangle(g2d, centerX, centerY, i, hexRadius, i % 2 == 0 ? color1 : color2);
|
||||
}
|
||||
}
|
||||
|
||||
g2d.setColor(getColorForTerrain(tile.getTerrain()));
|
||||
g2d.fillPolygon(hexagon);
|
||||
g2d.setColor(Color.BLACK);
|
||||
g2d.drawPolygon(hexagon);
|
||||
private void drawTriangle(Graphics2D g2d, int centerX, int centerY, int triangleIndex, int radius, Color color) {
|
||||
// Orientation de chaque triangle (décalage de 60° par rapport à chaque triangle)
|
||||
double angle = Math.toRadians(60 * triangleIndex);
|
||||
|
||||
// Calcul des points de chaque triangle autour du centre du grand hexagone
|
||||
int x1 = centerX + (int) (Math.cos(angle) * radius);
|
||||
int y1 = centerY + (int) (Math.sin(angle) * radius);
|
||||
|
||||
int x2 = centerX + (int) (Math.cos(angle + Math.toRadians(60)) * radius);
|
||||
int y2 = centerY + (int) (Math.sin(angle + Math.toRadians(60)) * radius);
|
||||
|
||||
int x3 = centerX + (int) (Math.cos(angle + Math.toRadians(120)) * radius);
|
||||
int y3 = centerY + (int) (Math.sin(angle + Math.toRadians(120)) * radius);
|
||||
|
||||
// Créer un polygone pour dessiner le triangle
|
||||
Polygon triangle = new Polygon();
|
||||
triangle.addPoint(centerX, centerY); // Centre de l'hexagone
|
||||
triangle.addPoint(x1, y1); // Premier sommet
|
||||
triangle.addPoint(x2, y2); // Deuxième sommet
|
||||
triangle.addPoint(x3, y3); // Troisième sommet
|
||||
|
||||
// Remplir le triangle avec la couleur
|
||||
g2d.setColor(color);
|
||||
g2d.fillPolygon(triangle);
|
||||
}
|
||||
|
||||
private Color getColorForTerrain(Terrain terrain) {
|
||||
return switch (terrain) {
|
||||
case MER -> Color.BLUE;
|
||||
case CHAMP -> Color.YELLOW;
|
||||
case FORET -> new Color(34, 139, 34);
|
||||
case PRE -> Color.GREEN;
|
||||
case MONTAGNE -> Color.GRAY;
|
||||
};
|
||||
switch (terrain) {
|
||||
case MER:
|
||||
return Color.BLUE;
|
||||
case CHAMP:
|
||||
return Color.YELLOW;
|
||||
case PRE:
|
||||
return Color.GREEN;
|
||||
case FORET:
|
||||
return new Color(34, 139, 34); // Vert foncé
|
||||
case MONTAGNE:
|
||||
return Color.GRAY;
|
||||
default:
|
||||
return Color.WHITE;
|
||||
}
|
||||
}
|
||||
|
||||
private Point calculateHexCoordinates(Point clickPoint) {
|
||||
int col = (int) Math.round((clickPoint.x - hexWidth / 2.0) / (1.5 * hexRadius));
|
||||
int row = (int) Math.round((clickPoint.y - hexHeight / 2.0 - (col % 2) * hexHeight / 4.0) / hexHeight);
|
||||
return new Point(col, row);
|
||||
private void handleMouseClick(int mouseX, int mouseY) {
|
||||
// Calcul des coordonnées de la grille de manière à respecter la structure hexagonale
|
||||
|
||||
// Calcul de la colonne et de la ligne en fonction de la taille des hexagones
|
||||
int gridX = (int) (mouseX / (hexWidth * 0.75)); // Calcul de la colonne
|
||||
|
||||
// Calcul de la ligne en fonction de la hauteur des hexagones
|
||||
int gridY = (int) (mouseY / hexHeight); // Calcul de la ligne
|
||||
|
||||
// Détecter si c'est une rangée paire ou impaire et appliquer un décalage
|
||||
if (gridY % 2 != 0) { // Si la ligne est impaire
|
||||
gridX += 1; // Décalage horizontal pour les rangées impaires
|
||||
}
|
||||
|
||||
private int calculateScreenX(Point position) {
|
||||
int col = position.x;
|
||||
return (int) (col * 1.5 * hexRadius + hexWidth / 2.0);
|
||||
}
|
||||
// Calculer les coordonnées X et Y en pixels
|
||||
int finalX = (int) (gridX * hexWidth * 0.75); // Calcul des coordonnées X
|
||||
int finalY = gridY * hexHeight; // Calcul des coordonnées Y
|
||||
|
||||
private int calculateScreenY(Point position) {
|
||||
int col = position.x;
|
||||
int row = position.y;
|
||||
return (int) (row * hexHeight + (col % 2) * hexHeight / 2.0 + hexHeight / 2.0);
|
||||
// Créer un objet Point avec les coordonnées finales
|
||||
Point position = new Point(finalX, finalY);
|
||||
|
||||
// Vérifier si la position est déjà occupée par une autre tuile
|
||||
if (!board.isPositionOccupied(position)) {
|
||||
// Créer une nouvelle tuile (ici, une tuile de forêt)
|
||||
Tile newTile = new Tile(Terrain.FORET);
|
||||
|
||||
// Ajouter la tuile sur le plateau
|
||||
board.addTile(position, newTile);
|
||||
|
||||
// Rafraîchir l'affichage
|
||||
repaint();
|
||||
}
|
||||
}
|
||||
}
|
Binary file not shown.
@@ -1,9 +1,15 @@
|
||||
public class Main {
|
||||
public static void main(String[] args) {
|
||||
// Création d'un plateau
|
||||
Board board = new Board();
|
||||
|
||||
// Vue avec le plateau
|
||||
GameView view = new GameView(board);
|
||||
|
||||
// Contrôleur
|
||||
GameController controller = new GameController(view);
|
||||
|
||||
// Démarrer le jeu
|
||||
controller.startGame();
|
||||
}
|
||||
}
|
Binary file not shown.
@@ -1,3 +1,3 @@
|
||||
public enum Terrain {
|
||||
MER, CHAMP, FORET, PRE, MONTAGNE
|
||||
MER, CHAMP, PRE, FORET, MONTAGNE, VIDE
|
||||
}
|
||||
|
Binary file not shown.
@@ -1,5 +1,5 @@
|
||||
public class Tile {
|
||||
private Terrain terrain;
|
||||
private Terrain terrain; // Un seul terrain pour toute la tuile
|
||||
|
||||
public Tile(Terrain terrain) {
|
||||
this.terrain = terrain;
|
||||
|
61
TestV1/TestEnAttendantResolutionBug/View/BoardView.java
Normal file
61
TestV1/TestEnAttendantResolutionBug/View/BoardView.java
Normal file
@@ -0,0 +1,61 @@
|
||||
package view;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.awt.event.MouseAdapter;
|
||||
import java.awt.event.MouseEvent;
|
||||
import model.Board;
|
||||
import model.Tile;
|
||||
import controller.GameController;
|
||||
|
||||
public class BoardView extends JPanel {
|
||||
private GameController controller;
|
||||
private int rows = 5;
|
||||
private int cols = 5;
|
||||
|
||||
public BoardView(Board board, GameController controller) {
|
||||
this.controller = controller;
|
||||
setLayout(new GridLayout(rows, cols, 5, 5));
|
||||
initializeBoard();
|
||||
}
|
||||
|
||||
// Méthode pour assigner le contrôleur après création de l'instance
|
||||
public void setController(GameController controller) {
|
||||
this.controller = controller;
|
||||
}
|
||||
|
||||
private void initializeBoard() {
|
||||
for (int i = 0; i < rows * cols; i++) {
|
||||
JPanel tilePanel = new JPanel();
|
||||
tilePanel.setBackground(Color.LIGHT_GRAY);
|
||||
tilePanel.setBorder(BorderFactory.createLineBorder(Color.BLACK));
|
||||
|
||||
tilePanel.addMouseListener(new MouseAdapter() {
|
||||
@Override
|
||||
public void mouseClicked(MouseEvent e) {
|
||||
handleTilePlacement(tilePanel);
|
||||
}
|
||||
});
|
||||
|
||||
add(tilePanel);
|
||||
}
|
||||
}
|
||||
|
||||
private void handleTilePlacement(JPanel tilePanel) {
|
||||
if (controller != null) { // Assure que le contrôleur est bien assigné
|
||||
Tile tile = controller.getNextTile();
|
||||
if (tile != null) {
|
||||
tilePanel.setBackground(Color.GREEN);
|
||||
tilePanel.add(new JLabel(tile.getType()));
|
||||
revalidate();
|
||||
repaint();
|
||||
controller.placeTile(tile);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void refreshBoard() {
|
||||
revalidate();
|
||||
repaint();
|
||||
}
|
||||
}
|
31
TestV1/TestEnAttendantResolutionBug/View/GameController.java
Normal file
31
TestV1/TestEnAttendantResolutionBug/View/GameController.java
Normal file
@@ -0,0 +1,31 @@
|
||||
package controller;
|
||||
|
||||
import model.Game;
|
||||
import model.Tile;
|
||||
import view.GameView;
|
||||
|
||||
public class GameController {
|
||||
private Game game;
|
||||
private GameView gameView;
|
||||
private Tile currentTile;
|
||||
|
||||
public GameController(Game game, GameView gameView) {
|
||||
this.game = game;
|
||||
this.gameView = gameView;
|
||||
this.currentTile = null; // Initialise sans tuile au début
|
||||
}
|
||||
|
||||
public void selectNextTile(Tile tile) {
|
||||
this.currentTile = tile;
|
||||
}
|
||||
|
||||
public Tile getNextTile() {
|
||||
return currentTile; // Retourne la tuile actuellement sélectionnée
|
||||
}
|
||||
|
||||
public void placeTile(Tile tile) {
|
||||
game.placeTile(tile);
|
||||
gameView.update(game);
|
||||
currentTile = null; // Réinitialise après placement
|
||||
}
|
||||
}
|
52
TestV1/TestEnAttendantResolutionBug/View/GameView.java
Normal file
52
TestV1/TestEnAttendantResolutionBug/View/GameView.java
Normal file
@@ -0,0 +1,52 @@
|
||||
package view;
|
||||
|
||||
import model.Game;
|
||||
import model.Tile;
|
||||
import controller.GameController;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
|
||||
public class GameView extends JFrame {
|
||||
private JLabel scoreLabel;
|
||||
private BoardView boardView;
|
||||
private GameController controller; // Ajoute le contrôleur ici
|
||||
|
||||
public GameView(Game game) { // Constructeur sans le contrôleur en paramètre
|
||||
setTitle("Dorfromantik en Java");
|
||||
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
||||
setSize(500, 500);
|
||||
setLayout(new BorderLayout());
|
||||
|
||||
scoreLabel = new JLabel("Score : " + game.getScore());
|
||||
boardView = new BoardView(game.getBoard(), null); // Initialise BoardView sans contrôleur
|
||||
|
||||
JButton nextTileButton = new JButton("Sélectionner une tuile");
|
||||
nextTileButton.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
if (controller != null) { // Vérifie que le contrôleur est bien assigné
|
||||
Tile tile = new Tile("forêt", new String[]{"terre", "terre", "eau", "terre", "eau", "terre"});
|
||||
controller.selectNextTile(tile);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
add(scoreLabel, BorderLayout.NORTH);
|
||||
add(boardView, BorderLayout.CENTER);
|
||||
add(nextTileButton, BorderLayout.SOUTH);
|
||||
}
|
||||
|
||||
// Nouvelle méthode setController pour permettre d'assigner le contrôleur après création
|
||||
public void setController(GameController controller) {
|
||||
this.controller = controller;
|
||||
boardView.setController(controller); // Passe le contrôleur à BoardView
|
||||
}
|
||||
|
||||
public void update(Game game) {
|
||||
scoreLabel.setText("Score : " + game.getScore());
|
||||
boardView.refreshBoard();
|
||||
}
|
||||
}
|
@@ -0,0 +1,20 @@
|
||||
package controller;
|
||||
|
||||
import model.Game;
|
||||
import model.Tile;
|
||||
import view.GameView;
|
||||
|
||||
public class GameController {
|
||||
private Game game;
|
||||
private GameView gameView;
|
||||
|
||||
public GameController(Game game, GameView gameView) {
|
||||
this.game = game;
|
||||
this.gameView = gameView;
|
||||
}
|
||||
|
||||
public void placeTile(Tile tile) {
|
||||
game.placeTile(tile);
|
||||
gameView.update(game);
|
||||
}
|
||||
}
|
26
TestV1/TestEnAttendantResolutionBug/model/Board.java
Normal file
26
TestV1/TestEnAttendantResolutionBug/model/Board.java
Normal file
@@ -0,0 +1,26 @@
|
||||
package model;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class Board {
|
||||
private List<Tile> tiles;
|
||||
|
||||
public Board() {
|
||||
tiles = new ArrayList<>();
|
||||
}
|
||||
|
||||
public void addTile(Tile tile) {
|
||||
tiles.add(tile);
|
||||
}
|
||||
|
||||
public List<Tile> getTiles() {
|
||||
return tiles;
|
||||
}
|
||||
|
||||
public boolean isPlacementValid(Tile tile) {
|
||||
// Logique simplifiée pour vérifier si la tuile peut être placée
|
||||
// Ici, tu pourrais vérifier les bords de la tuile et du plateau
|
||||
return true; // Retourne true pour simplifier
|
||||
}
|
||||
}
|
26
TestV1/TestEnAttendantResolutionBug/model/Game.java
Normal file
26
TestV1/TestEnAttendantResolutionBug/model/Game.java
Normal file
@@ -0,0 +1,26 @@
|
||||
package model;
|
||||
|
||||
public class Game {
|
||||
private Board board;
|
||||
private int score;
|
||||
|
||||
public Game() {
|
||||
board = new Board();
|
||||
score = 0;
|
||||
}
|
||||
|
||||
public Board getBoard() {
|
||||
return board;
|
||||
}
|
||||
|
||||
public int getScore() {
|
||||
return score;
|
||||
}
|
||||
|
||||
public void placeTile(Tile tile) {
|
||||
if (board.isPlacementValid(tile)) {
|
||||
board.addTile(tile);
|
||||
score += 10; // Par exemple, chaque tuile ajoute 10 points
|
||||
}
|
||||
}
|
||||
}
|
19
TestV1/TestEnAttendantResolutionBug/model/Tile.java
Normal file
19
TestV1/TestEnAttendantResolutionBug/model/Tile.java
Normal file
@@ -0,0 +1,19 @@
|
||||
package model;
|
||||
|
||||
public class Tile {
|
||||
private String type; // Par exemple : "forêt", "rivière", "champ", etc.
|
||||
private String[] edges; // Les types des bords de la tuile (ex: "eau", "terre")
|
||||
|
||||
public Tile(String type, String[] edges) {
|
||||
this.type = type;
|
||||
this.edges = edges;
|
||||
}
|
||||
|
||||
public String getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public String getEdge(int index) {
|
||||
return edges[index];
|
||||
}
|
||||
}
|
24
TestV1/TestEnAttendantResolutionBug/view/BoardView.java
Normal file
24
TestV1/TestEnAttendantResolutionBug/view/BoardView.java
Normal file
@@ -0,0 +1,24 @@
|
||||
package view;
|
||||
|
||||
import javax.swing.*;
|
||||
import model.Board;
|
||||
import model.Tile;
|
||||
import java.awt.*;
|
||||
|
||||
public class BoardView extends JPanel {
|
||||
private Board board;
|
||||
|
||||
public BoardView(Board board) {
|
||||
this.board = board;
|
||||
setLayout(new GridLayout(5, 5, 5, 5)); // Exemple de grille 5x5 pour le plateau
|
||||
}
|
||||
|
||||
public void refreshBoard() {
|
||||
removeAll();
|
||||
for (Tile tile : board.getTiles()) {
|
||||
add(new TileView(tile.getType()));
|
||||
}
|
||||
revalidate();
|
||||
repaint();
|
||||
}
|
||||
}
|
28
TestV1/TestEnAttendantResolutionBug/view/GameView.java
Normal file
28
TestV1/TestEnAttendantResolutionBug/view/GameView.java
Normal file
@@ -0,0 +1,28 @@
|
||||
package view;
|
||||
|
||||
import model.Game;
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
|
||||
public class GameView extends JFrame {
|
||||
private JLabel scoreLabel;
|
||||
private BoardView boardView;
|
||||
|
||||
public GameView(Game game) {
|
||||
setTitle("Dorfromantik en Java");
|
||||
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
||||
setSize(400, 400);
|
||||
setLayout(new BorderLayout());
|
||||
|
||||
scoreLabel = new JLabel("Score : " + game.getScore());
|
||||
boardView = new BoardView(game.getBoard());
|
||||
|
||||
add(scoreLabel, BorderLayout.NORTH);
|
||||
add(boardView, BorderLayout.CENTER);
|
||||
}
|
||||
|
||||
public void update(Game game) {
|
||||
scoreLabel.setText("Score : " + game.getScore());
|
||||
boardView.refreshBoard();
|
||||
}
|
||||
}
|
21
TestV1/TestEnAttendantResolutionBug/view/TileView.java
Normal file
21
TestV1/TestEnAttendantResolutionBug/view/TileView.java
Normal file
@@ -0,0 +1,21 @@
|
||||
package view;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
|
||||
public class TileView extends JPanel {
|
||||
private String type;
|
||||
|
||||
public TileView(String type) {
|
||||
this.type = type;
|
||||
setPreferredSize(new Dimension(50, 50)); // Taille de la tuile
|
||||
setBackground(Color.LIGHT_GRAY);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void paintComponent(Graphics g) {
|
||||
super.paintComponent(g);
|
||||
g.setColor(Color.BLACK);
|
||||
g.drawString(type, 10, 25); // Affiche le type de la tuile au centre
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user