Commit 9e8247a5 authored by YuFan Jia's avatar YuFan Jia 💤
Browse files

Merge branch 'Front' into 'main'

fix(test): test

See merge request !5
parents e23de59d 5acffb3f
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -6,6 +6,7 @@ public class Main {
    public static void main(String[] args) {
        SwingUtilities.invokeLater(() -> {

            
            GameFrame mainFrame = new GameFrame(800);
            mainFrame.setVisible(true);
        });
+2 −2
Original line number Diff line number Diff line
@@ -54,10 +54,10 @@ public class ChessGridComponent extends BasicComponent {

    public void drawPiece(Graphics g) {
        g.setColor(gridColor);
        g.fillRect(1, 1, this.getWidth() - 2, this.getHeight() - 2);
        g.fillRect(1, 1, this.getWidth() - 2, this.getHeight() - 2);//fill the rect with chessboard color
        if (this.chessPiece != null) {
            g.setColor(chessPiece.getColor());
            g.fillOval((gridSize - chessSize) / 2, (gridSize - chessSize) / 2, chessSize, chessSize);
            g.fillOval((gridSize - chessSize) / 2, (gridSize - chessSize) / 2, chessSize, chessSize);//draw a point
        }
    }

+7 −9
Original line number Diff line number Diff line
package view;


import controller.GameController;

import javax.swing.*;
@@ -22,9 +21,9 @@ public class GameFrame extends JFrame {

        this.setLocationRelativeTo(null);


        chessBoardPanel = new ChessBoardPanel((int) (this.getWidth() * 0.8), (int) (this.getHeight() * 0.7));
        chessBoardPanel.setLocation((this.getWidth() - chessBoardPanel.getWidth()) / 2, (this.getHeight() - chessBoardPanel.getHeight()) / 3);
        chessBoardPanel.setLocation((this.getWidth() - chessBoardPanel.getWidth()) / 2,
                (this.getHeight() - chessBoardPanel.getHeight()) / 3);

        statusPanel = new StatusPanel((int) (this.getWidth() * 0.8), (int) (this.getHeight() * 0.1));
        statusPanel.setLocation((this.getWidth() - chessBoardPanel.getWidth()) / 2, 0);
@@ -34,10 +33,10 @@ public class GameFrame extends JFrame {
        this.add(chessBoardPanel);
        this.add(statusPanel);


        JButton restartBtn = new JButton("Restart");
        restartBtn.setSize(120, 50);
        restartBtn.setLocation((this.getWidth() - chessBoardPanel.getWidth()) / 2, (this.getHeight() + chessBoardPanel.getHeight()) / 2);
        restartBtn.setLocation((this.getWidth() - chessBoardPanel.getWidth()) / 2,
                (this.getHeight() + chessBoardPanel.getHeight()) / 2);
        add(restartBtn);
        restartBtn.addActionListener(e -> {
            System.out.println("click restart Btn");
@@ -63,7 +62,6 @@ public class GameFrame extends JFrame {
            controller.writeDataToFile(filePath);
        });


        this.setVisible(true);
        this.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);