Skip to content

Commit

Permalink
改了很多
Browse files Browse the repository at this point in the history
  • Loading branch information
ShellyLeee committed Dec 23, 2022
1 parent 8218073 commit d5ee8c0
Show file tree
Hide file tree
Showing 3 changed files with 80 additions and 91 deletions.
Binary file modified out/production/DarkChess-master/view/ChessGameFrame.class
Binary file not shown.
20 changes: 10 additions & 10 deletions recordByStep/9.txt
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
C0 f0 F0 d0
G0 F0 a0 f0
e0 C0 A1 g1
a1 e1 A1 A1
E0 B1 c1 D1
A0 a0 D0 b0
d0 c0 a0 B0
A0 a0 E0 b0
5
Red is the next
B0 a0 e1 e1
D0 C1 c1 f1
A0 A1 C1 g1
E0 A0 b0 B1
a0 A0 d0 c1
f0 F0 a0 b0
G0 F0 E0 a0
A0 a0 D0 d0
6
Black is the next
0
0
151 changes: 70 additions & 81 deletions src/view/ChessGameFrame.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
* 3 JButton: 按钮
*/
public class ChessGameFrame extends JFrame implements ActionListener {
int click = 0;
MyThread t01 = new MyThread("111");
public JButton changeBG;
public JButton regret;
Expand Down Expand Up @@ -104,7 +105,7 @@ public ChessGameFrame(int width, int height) {
judgeWinner();
addProgressS();
//增加背景图片(最后)
ImageIcon bg = new ImageIcon("imgs/对奕背景.png");
ImageIcon bg = new ImageIcon("imgs/对弈背景1.png");
BackLabel = new JLabel(bg);
BackLabel.setSize(bg.getIconWidth(), bg.getIconHeight());
this.getLayeredPane().add(BackLabel, new Integer(Integer.MIN_VALUE));
Expand All @@ -116,20 +117,32 @@ public ChessGameFrame(int width, int height) {
* 一键换背景
*/
public void changeBackground(){
ImageIcon bg1 = new ImageIcon("imgs/对弈背景2.png");
BackLabel.setIcon(bg1);
ImageIcon bg1 = new ImageIcon("imgs/对弈背景1.png");
ImageIcon bg2 = new ImageIcon("imgs/对弈背景2.png");
ImageIcon bg3 = new ImageIcon("imgs/对弈背景3.png");
if(click == 1){
BackLabel.setIcon(bg2);
}
if(click == 2){
BackLabel.setIcon(bg3);
}
if(click == 3){
BackLabel.setIcon(bg1);
click = 0;
}
}
public void addChangeBG(){
changeBG = new JButton("换BG");
changeBG = new JButton("换装");
changeBG.setSize(50,50);
changeBG.setLocation(50,50);
changeBG.setLocation(10,10);
add(changeBG);
setVisible(true);
changeBG.addActionListener(e -> {
String path1 = "Music/大按钮的副本.wav";
Test.AudioPlay2 clickMusic = new Test.AudioPlay2(path1);
clickMusic.run = true;
clickMusic.start();
click++;
changeBackground();
});

Expand Down Expand Up @@ -165,7 +178,7 @@ public static JLabel getBeginLabel() {
* 在游戏窗体中增加一个按钮,如果按下的话就会显示是否重新开始游戏
*/
private void addRestartButton() {
JButton button = new JButton("Restart");
JButton button = new JButton(new ImageIcon("imgs/replay.png"));
button.addActionListener((e) -> {
String path = "Music/大按钮的副本.wav";
Test.AudioPlay2 clickMusic = new Test.AudioPlay2(path);
Expand All @@ -178,15 +191,14 @@ private void addRestartButton() {
gameController.restartGame();
}
});
button.setLocation(WIDTH * 3 / 5, HEIGHT / 10 + 60);
button.setSize(100, 60);
button.setFont(new Font("Rockwell", Font.BOLD, 20));
button.setLocation(WIDTH * 9 / 10 - 10, 10);
button.setSize(32, 32);
add(button);
setVisible(true);
}

private void addExitButton() {
JButton button = new JButton("Exit");
JButton button = new JButton(new ImageIcon("imgs/cancel.png"));
button.addActionListener((e) -> {
String path = "Music/大按钮的副本.wav";
Test.AudioPlay2 clickMusic = new Test.AudioPlay2(path);
Expand All @@ -199,9 +211,8 @@ private void addExitButton() {
Menu menu = new Menu(720, 720);
}
});
button.setLocation(WIDTH * 3 / 5 + 100, HEIGHT / 10 + 60);
button.setSize(80, 60);
button.setFont(new Font("Rockwell", Font.BOLD, 20));
button.setLocation(WIDTH * 9 / 10 + 30, 10);
button.setSize(32, 32);
add(button);
setVisible(true);
}
Expand All @@ -211,7 +222,7 @@ private void addExitButton() {
*/
private void addLoadButton() {
JButton button = new JButton("Load");
button.setLocation(WIDTH * 3 / 5, HEIGHT / 10 + 130);
button.setLocation(WIDTH * 3 / 5, HEIGHT / 10 + 70);
button.setSize(100, 60);
button.setFont(new Font("Rockwell", Font.BOLD, 20));
button.setBackground(Color.LIGHT_GRAY);
Expand All @@ -232,7 +243,7 @@ private void addLoadButton() {
*/
public void addSaveButton() {
JButton button = new JButton("Save");
button.setLocation(WIDTH * 3 / 5 + 100, HEIGHT / 10 + 130);
button.setLocation(WIDTH * 3 / 5 + 100, HEIGHT / 10 + 70);
button.setSize(80, 60);
button.setFont(new Font("Rockwell", Font.BOLD, 20));
button.setBackground(Color.LIGHT_GRAY);
Expand All @@ -259,22 +270,25 @@ public void addSaveButton() {
*/
private void addCheatingBottom() {
Cheat = new JButton("Cheat");
Cheat.setLocation(WIDTH * 3 / 5 + 10, HEIGHT / 10 + 200);
Cheat.setLocation(WIDTH * 3 / 5 + 100, HEIGHT / 10 + 130);
Cheat.setSize(80, 60);
Cheat.setFont(new Font("Rockwell", Font.BOLD, 20));
add(Cheat);
Cheat.addActionListener(this::actionPerformed);
Cheat.setVisible(true);
close = new JButton("Close");
close.setLocation(WIDTH * 3 / 5 + 90, HEIGHT / 10 + 200);
close.setLocation(WIDTH * 3 / 5 + 100, HEIGHT / 10 + 130);
close.setSize(80, 60);
close.setFont(new Font("Rockwell", Font.BOLD, 20));
add(close);
close.addActionListener(this::actionPerformed);
setVisible(true);
close.setVisible(false);
}

public void actionPerformed(ActionEvent e) {//不要点2次cheat!!
if (e.getSource() == Cheat) {
Cheat.setVisible(false);
close.setVisible(true);
String path = "Music/大按钮的副本.wav";
Test.AudioPlay2 clickMusic = new Test.AudioPlay2(path);
clickMusic.run = true;
Expand All @@ -293,6 +307,8 @@ public void actionPerformed(ActionEvent e) {//不要点2次cheat!!
setVisible(true);
}
if (e.getSource() == close) {
Cheat.setVisible(true);
close.setVisible(false);
String path = "Music/大按钮的副本.wav";
Test.AudioPlay2 clickMusic = new Test.AudioPlay2(path);
clickMusic.run = true;
Expand All @@ -314,8 +330,8 @@ public void actionPerformed(ActionEvent e) {//不要点2次cheat!!
public void addRegret() {
regret = new JButton("Regret");
regret.setSize(100, 60);
regret.setLocation(0, 10);
regret.setFont(new Font("Rockwell", Font.BOLD, 16));
regret.setLocation(WIDTH*3/5, HEIGHT*1/10 + 130);
regret.setFont(new Font("Rockwell", Font.BOLD, 20));
add(regret);
regret.setVisible(true);
regret.addActionListener(e -> {
Expand Down Expand Up @@ -373,48 +389,35 @@ private void addBlackCredit () {

private void addRedKilled () {
//加Label
JLabel General = new JLabel("帥");
General.setForeground(Color.RED);
General.setFont(new Font("Rockwell", Font.BOLD, 18));
General.setLocation(WIDTH * 3 / 5 - 3, 565);
JLabel General = new JLabel(new ImageIcon("imgs/小红帅.png"));
General.setLocation(WIDTH * 3 / 5 - 55, 565);
General.setSize(100, 100);
add(General);
JLabel Advisor = new JLabel("仕");
Advisor.setForeground(Color.RED);
Advisor.setFont(new Font("Rockwell", Font.BOLD, 18));
Advisor.setLocation(WIDTH * 3 / 5 - 3, 535);
JLabel Advisor = new JLabel(new ImageIcon("imgs/小红士.png"));
Advisor.setLocation(WIDTH * 3 / 5 - 55, 535);
Advisor.setSize(100, 100);
add(Advisor);
JLabel Minister = new JLabel("相");
Minister.setForeground(Color.RED);
Minister.setFont(new Font("Rockwell", Font.BOLD, 18));
Minister.setLocation(WIDTH * 3 / 5 - 3, 505);
JLabel Minister = new JLabel(new ImageIcon("imgs/小红相.png"));
Minister.setLocation(WIDTH * 3 / 5 - 55, 505);
Minister.setSize(100, 100);
add(Minister);
JLabel Horse = new JLabel("傌");
Horse.setForeground(Color.RED);
Horse.setFont(new Font("Rockwell", Font.BOLD, 18));
Horse.setLocation(WIDTH * 3 / 5 - 3, 475);
JLabel Horse = new JLabel(new ImageIcon("imgs/小红马.png"));
Horse.setLocation(WIDTH * 3 / 5 - 55, 475);
Horse.setSize(100, 100);
add(Horse);
JLabel Chariot = new JLabel("俥");
Chariot.setForeground(Color.RED);
Chariot.setFont(new Font("Rockwell", Font.BOLD, 18));
Chariot.setLocation(WIDTH * 3 / 5 - 3, 445);
JLabel Chariot = new JLabel(new ImageIcon("imgs/小红车.png"));
Chariot.setLocation(WIDTH * 3 / 5 - 55, 445);
Chariot.setSize(100, 100);
add(Chariot);
JLabel Cannon = new JLabel("炮");
Cannon.setForeground(Color.RED);
Cannon.setFont(new Font("Rockwell", Font.BOLD, 18));
Cannon.setLocation(WIDTH * 3 / 5 - 3, 415);
JLabel Cannon = new JLabel(new ImageIcon("imgs/小红炮.png"));
Cannon.setLocation(WIDTH * 3 / 5 - 55, 415);
Cannon.setSize(100, 100);
add(Cannon);
JLabel Soldier = new JLabel("兵");
Soldier.setForeground(Color.RED);
Soldier.setFont(new Font("Rockwell", Font.BOLD, 18));
Soldier.setLocation(WIDTH * 3 / 5 - 3, 385);
Soldier.setSize(100, 100);
JLabel Soldier = new JLabel(new ImageIcon("imgs/小红兵.png"));
Soldier.setLocation(WIDTH * 3 / 5 - 55, 385);
Soldier.setSize(100,100);
add(Soldier);

RGeneral.setFont(new Font("Rockwell", Font.BOLD, 18));
RGeneral.setEditable(false);
RAdvisor.setFont(new Font("Rockwell", Font.BOLD, 18));
Expand Down Expand Up @@ -455,46 +458,32 @@ private void addRedKilled () {
}
private void addBlackKilled () {//可能要加actionListener
//加Label
JLabel General = new JLabel("將");
General.setForeground(Color.BLACK);
General.setFont(new Font("Rockwell", Font.BOLD, 18));
General.setLocation(WIDTH * 8 / 9 - 20, 565);
JLabel General = new JLabel(new ImageIcon("imgs/小黑将.png"));
General.setLocation(WIDTH * 8 / 9 - 70, 565);
General.setSize(100, 100);
add(General);
JLabel Advisor = new JLabel("士");
Advisor.setForeground(Color.BLACK);
Advisor.setFont(new Font("Rockwell", Font.BOLD, 18));
Advisor.setLocation(WIDTH * 8 / 9 - 20, 535);
JLabel Advisor = new JLabel(new ImageIcon("imgs/小黑士.png"));
Advisor.setLocation(WIDTH * 8 / 9 - 70, 535);
Advisor.setSize(100, 100);
add(Advisor);
JLabel Minister = new JLabel("象");
Minister.setForeground(Color.BLACK);
Minister.setFont(new Font("Rockwell", Font.BOLD, 18));
Minister.setLocation(WIDTH * 8 / 9 - 20, 505);
JLabel Minister = new JLabel(new ImageIcon("imgs/小黑象.png"));
Minister.setLocation(WIDTH * 8 / 9 - 70, 505);
Minister.setSize(100, 100);
add(Minister);
JLabel Horse = new JLabel("馬");
Horse.setForeground(Color.BLACK);
Horse.setFont(new Font("Rockwell", Font.BOLD, 18));
Horse.setLocation(WIDTH * 8 / 9 - 20, 475);
JLabel Horse = new JLabel(new ImageIcon("imgs/小黑马.png"));
Horse.setLocation(WIDTH * 8 / 9 - 70, 475);
Horse.setSize(100, 100);
add(Horse);
JLabel Chariot = new JLabel("車");
Chariot.setForeground(Color.BLACK);
Chariot.setFont(new Font("Rockwell", Font.BOLD, 18));
Chariot.setLocation(WIDTH * 8 / 9 - 20, 445);
JLabel Chariot = new JLabel(new ImageIcon("imgs/小黑车.png"));
Chariot.setLocation(WIDTH * 8 / 9 - 70, 445);
Chariot.setSize(100, 100);
add(Chariot);
JLabel Cannon = new JLabel("砲");
Cannon.setForeground(Color.BLACK);
Cannon.setFont(new Font("Rockwell", Font.BOLD, 18));
Cannon.setLocation(WIDTH * 8 / 9 - 20, 415);
JLabel Cannon = new JLabel(new ImageIcon("imgs/小黑炮.png"));
Cannon.setLocation(WIDTH * 8 / 9 - 70, 415);
Cannon.setSize(100, 100);
add(Cannon);
JLabel Soldier = new JLabel("卒");
Soldier.setForeground(Color.BLACK);
Soldier.setFont(new Font("Rockwell", Font.BOLD, 18));
Soldier.setLocation(WIDTH * 8 / 9 - 20, 385);
JLabel Soldier = new JLabel(new ImageIcon("imgs/小黑卒.png"));
Soldier.setLocation(WIDTH * 8 / 9 - 70, 385);
Soldier.setSize(100, 100);
add(Soldier);

Expand Down Expand Up @@ -586,14 +575,14 @@ public void judgeWinner () {
}
}
public void addMusicButton () {
noMusic = new JButton("静音");
noMusic = new JButton(new ImageIcon("imgs/pause.png"));
noMusic.setSize(30, 30);
noMusic.setLocation(WIDTH * 9 / 10 - 10, 10);
noMusic.setLocation(WIDTH * 1/2 +30, 20);
add(noMusic);
noMusic.addActionListener(this::actionMusic);
music = new JButton("声音");
music = new JButton(new ImageIcon("imgs/play.png"));
music.setSize(30, 30);
music.setLocation(WIDTH * 9 / 10 + 30, 10);
music.setLocation(WIDTH * 1/2 + 70, 20);
add(music);
setVisible(true);
music.addActionListener(this::actionMusic);
Expand Down

0 comments on commit d5ee8c0

Please sign in to comment.