|
|
|
@ -1,16 +1,24 @@
|
|
|
|
|
package com.sheep.view;
|
|
|
|
|
|
|
|
|
|
import com.sheep.model.Brand;
|
|
|
|
|
import com.sheep.util.MapUtil;
|
|
|
|
|
|
|
|
|
|
import javax.swing.*;
|
|
|
|
|
import java.awt.event.ActionEvent;
|
|
|
|
|
import java.awt.event.ActionListener;
|
|
|
|
|
import java.awt.event.MouseAdapter;
|
|
|
|
|
import java.awt.event.MouseEvent;
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
开始界面
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
public class Start extends JFrame {
|
|
|
|
|
Integer gameMode;
|
|
|
|
|
JLabel backgroundLabel = new JLabel(new ImageIcon("imgs/背景1.png"));
|
|
|
|
|
|
|
|
|
|
public Start() {
|
|
|
|
|
gameMode = 1;
|
|
|
|
|
init();//初始化窗口
|
|
|
|
|
|
|
|
|
|
//添加背景及按钮
|
|
|
|
@ -34,19 +42,64 @@ public class Start extends JFrame {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void addBackgound(){
|
|
|
|
|
JLabel gameMode1 = new JLabel(new ImageIcon("imgs/刷子.png"));
|
|
|
|
|
gameMode1.setBounds(100,550,50,50);
|
|
|
|
|
this.add(gameMode1);
|
|
|
|
|
|
|
|
|
|
JLabel gameMode2 = new JLabel(new ImageIcon("imgs/羊1.png"));
|
|
|
|
|
gameMode2.setBounds(200,550,50,50);
|
|
|
|
|
this.add(gameMode2);
|
|
|
|
|
|
|
|
|
|
JLabel gameMode3 = new JLabel(new ImageIcon("imgs/羊1.png"));
|
|
|
|
|
gameMode3.setBounds(300,550,50,50);
|
|
|
|
|
this.add(gameMode3);
|
|
|
|
|
|
|
|
|
|
JButton startButton = new JButton(new ImageIcon("imgs/开始.png"));
|
|
|
|
|
startButton.setBounds(125,400,200,50);
|
|
|
|
|
this.add(startButton);
|
|
|
|
|
|
|
|
|
|
JLabel backgroungLabel = new JLabel(new ImageIcon("imgs/背景.png"));
|
|
|
|
|
backgroungLabel.setBounds(0,0,450,800);
|
|
|
|
|
this.add(backgroungLabel);
|
|
|
|
|
|
|
|
|
|
backgroundLabel.setBounds(0,0,450,800);
|
|
|
|
|
this.add(backgroundLabel);
|
|
|
|
|
|
|
|
|
|
//游戏模式1监听事件
|
|
|
|
|
gameMode1.addMouseListener(new MouseAdapter() {
|
|
|
|
|
@Override
|
|
|
|
|
public void mouseClicked(MouseEvent e) {
|
|
|
|
|
gameMode = 1;
|
|
|
|
|
|
|
|
|
|
backgroundLabel.setIcon(new ImageIcon("imgs/背景1.png"));
|
|
|
|
|
backgroundLabel.repaint();
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
//游戏模式2监听事件
|
|
|
|
|
gameMode2.addMouseListener(new MouseAdapter() {
|
|
|
|
|
@Override
|
|
|
|
|
public void mouseClicked(MouseEvent e) {
|
|
|
|
|
gameMode = 2;
|
|
|
|
|
|
|
|
|
|
backgroundLabel.setIcon(new ImageIcon("imgs/背景2.png"));
|
|
|
|
|
backgroundLabel.repaint();
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
//游戏模式3监听事件
|
|
|
|
|
gameMode3.addMouseListener(new MouseAdapter() {
|
|
|
|
|
@Override
|
|
|
|
|
public void mouseClicked(MouseEvent e) {
|
|
|
|
|
gameMode = 2;
|
|
|
|
|
|
|
|
|
|
backgroundLabel.setIcon(new ImageIcon("imgs/背景3.png"));
|
|
|
|
|
backgroundLabel.repaint();
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
//按钮添加监听事件
|
|
|
|
|
startButton.addActionListener(new ActionListener() {
|
|
|
|
|
@Override
|
|
|
|
|
public void actionPerformed(ActionEvent e) {
|
|
|
|
|
new Game();
|
|
|
|
|
new Game(gameMode);
|
|
|
|
|
Start.super.dispose();
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
@ -72,7 +125,4 @@ public class Start extends JFrame {
|
|
|
|
|
}).start();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static void main(String[] args) {
|
|
|
|
|
new Start();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|