added a class that could be implemented with more work and time.

This commit is contained in:
Jerome ALTARIBA 2025-05-23 23:27:31 +02:00
parent a3e65fcb81
commit efd5d21f19
3 changed files with 11 additions and 5 deletions

View File

@ -13,7 +13,6 @@ public class Main {
Board testBoard = new Board(8, 8);
testBoard.populateBoard();
System.out.println(testBoard.toString());
// launches graphical interface :
MyInterface mjf = new MyInterface();
mjf.setVisible(true);

View File

@ -11,6 +11,9 @@ public class Board {
Piece selectedCell;
private ArrayList<Move> moveHistory = new ArrayList<>();
public Piece enPassantTargetPawn = null;
public Interface Color;
int turnNumber = 0;
@ -20,6 +23,7 @@ public class Board {
lNum=lineNum;
cells = new Piece[cNum][lNum]; // creation du tableau de pieces
selectedCell=null;
}
public int getWidth() {
@ -34,7 +38,6 @@ public class Board {
return turnNumber;
}
public boolean isTurnWhite() {
return getTurnNumber() % 2 == 0;
}
@ -44,8 +47,8 @@ public class Board {
Piece newPiece = new Piece(type, isWhite, x, y);
cells[x][y] = newPiece;
}
public void populateBoard() {

View File

@ -16,6 +16,7 @@ import javax.swing.JPanel;
import backend.Game;
import backend.Piece;
import backend.PieceType;
import backend.Interface;
public class JPanelChessBoard extends JPanel {
@ -31,6 +32,9 @@ public class JPanelChessBoard extends JPanel {
private boolean selectedPieceIsWhite;
private PieceType selectedPieceType;
private boolean pieceAdderMode;
private Interface color;
public JPanelChessBoard(MyInterface itf) {
super();
@ -81,7 +85,7 @@ public class JPanelChessBoard extends JPanel {
@Override
protected void paintComponent(Graphics g) {
super.paintComponent(g);
this.setBackground(Color.PINK);
this.setBackground(Color.DARK_GRAY);
if(pieceSelectorMode) {
g.drawImage(
spriteSheet,