package kyodai;
import javax.swing.*;
import java.awt.*;
import java.net.*;
import java.awt.event.*;
import javax.swing.border.*;
import kyodai.map.*;
import kyodai.topbar.*;
/**
* 连连看主类
*/
public class Kyodai extends JFrame
implements ActionListener {
public static Color DarkColor = new Color(55, 77, 118); //暗色
public static Color LightColor = new Color(111, 146, 212); //亮色
public static ImageIcon[] BlocksIcon = new ImageIcon[39]; //游戏中方块的图标
public static ImageIcon GuideIcon; //连线的图标
public static Border unSelected = BorderFactory.createLineBorder(DarkColor, 1); //未选中时的边框
public static Border Selected = BorderFactory.createLineBorder(Color.white, 1); //选中后的边框
public static Border Hint = BorderFactory.createLineBorder(Color.green, 1); //提示的边框
Dimension faceSize = new Dimension(780, 500);
Image icon;
private int counter = 0;
JPanel toolBar = new JPanel(); //工具栏
JPanel actionPanel = new JPanel(); //用户操作栏
JPanel contentPanel = new JPanel(); //容器
JPanel statusPanel = new JPanel(); //状态栏
Border emptyBorder = BorderFactory.createEmptyBorder(); //未选中时的边框
JButton startButton = new JButton(); //"开始"
JButton refreshButton = new JButton(); //"刷新"
JButton hintButton = new JButton(); //"提示"
JButton bombButton = new JButton(); //"炸弹"
JButton demoButton = new JButton(); //"演示"
JButton setupButton = new JButton(); //设置
JButton helpButton = new JButton(); //帮助
JButton aboutButton = new JButton(); //关于
JButton goTop10 = new JButton("Go top 10");
HelpDialog helpDialog; //帮助对话框
AboutDialog aboutDialog; //关于对话框
public static JTextField statusField = new JTextField(
"欢迎使用宝石连连看");
ImageIcon imgStart, imgHint, imgRefresh, imgBomb, imgDemo;
ImageIcon imgSetup, imgHelp, imgAbout;
JButton[] dots = new JButton[Setting.ROW * Setting.COLUMN];
Setting setting = new Setting();
MapUI ui;
Map map;
ClockAnimate clock = new ClockAnimate(); //时钟
ScoreAnimate score = new ScoreAnimate(); //分数
AnimateDelete animateDelete = new AnimateDelete(dots);
Music music = new Music();
public Kyodai() {
initResource();//初始化系统所需要的资源
map = new Map();
ui = new MapUI(map, dots);
initUI();//初始化用户界面
ui.setScore(score);
ui.setClock(clock);
ui.setTop10Button(goTop10);
animateDelete.setSpeed(setting.Animate);
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
this.pack();
this.setSize(faceSize);
//设置运行时窗口的位置
Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
this.setLocation( (int) (screenSize.width - faceSize.getWidth()) / 2,
(int) (screenSize.height - faceSize.getHeight()) / 2);
this.setResizable(false);
this.setTitle("宝石连连看"); //设置标题
this.setIconImage(icon); //设置程序图标
//设置动画光标
URLClassLoader urlLoader = (URLClassLoader)this.getClass().getClassLoader();
URL url = urlLoader.findResource("images/cursor.gif");
Image animateImage = new ImageIcon(url).getImage();
Cursor cursor = Toolkit.getDefaultToolkit().createCustomCursor(
animateImage, new Point(0, 0), "cursor");
this.setCursor(cursor);
this.addWindowListener(
new WindowAdapter() {
public void windowClosing(WindowEvent we) {
setting.save();
}
}
);
if (setting.Music == 1) {
music.play();
}
}
/**
* 初始化系统所需要的资源
*/
public void initResource() {
URLClassLoader urlLoader = (URLClassLoader)this.getClass().getClassLoader();
URL url;
//程序图标
icon = getImage("images/kyodai16.gif");
for (int i = 0; i < BlocksIcon.length; i++) {
BlocksIcon[i] = new ImageIcon(getImage("images/" + (i + 1) + ".gif"));
}
imgStart = new ImageIcon(getImage("images/start.gif"));
imgRefresh = new ImageIcon(getImage("images/refresh.gif"));
imgHint = new ImageIcon(getImage("images/hint.gif"));
imgBomb = new ImageIcon(getImage("images/bomb.gif"));
imgDemo = new ImageIcon(getImage("images/demo.gif"));
imgSetup = new ImageIcon(getImage("images/setup.gif"));
imgHelp = new ImageIcon(getImage("images/help.gif"));
imgAbout = new ImageIcon(getImage("images/about.gif"));
GuideIcon = new ImageIcon(getImage("images/dots.gif"));
//初始化方块
for (int i = 0; i < dots.length; i++) {
dots[i] = new JButton();
dots[i].setActionCommand("" + i);
dots[i].setBorder(unSelected);
dots[i].setBackground(DarkColor);
}
//读取用户设置
setting.load();
//初始化对话框
helpDialog = new HelpDialog(this); //帮助对话框
aboutDialog = new AboutDialog(this); //关于对话框
}
/**
* 初始化用户界面
*/
public void initUI() {
//界面整体布局
Border border = BorderFactory.createBevelBorder(BevelBorder.LOWERED,
new Color(45, 92, 162),
new Color(43, 66, 97),
new Color(45, 92, 162),
new Color(84, 123, 200));
BorderLayout borderLayout = new BorderLayout();
toolBar.setBackground(DarkColor);
toolBar.setBorder(border);
toolBar.setPreferredSize(new Dimension(780, 48));
toolBar.setMinimumSize(new Dimension(780, 48));
toolBar.setLayout(new FlowLayout(FlowLayout.LEFT));
actionPanel.setBackground(LightColor);
actionPanel.setBorder(border);
actionPanel.setPreferredSize(new Dimension(160, 380));
actionPanel.setMinimumSize(new Dimension(160, 380));
contentPanel.setBackground(DarkColor);
contentPanel.setBorder(border);
contentPanel.setPreferredSize(new Dimension(620, 380));
contentPanel.setMinimumSize(new Dimension(620, 380));
statusPanel.setBackground(DarkColor);
statusPanel.setBorder(border);
statusPanel.setPreferredSize(new Dimension(620, 24));
statusPanel.setMinimumSize(new Dimension(620, 24));
statusPanel.setLayout(new BorderLayout());
this.getContentPane().setLayout(borderLayout);
this.getContentPane().add(toolBar, BorderLayout.NORTH);
this.getContentPane().add(actionPanel, BorderLayout.EAST);
this.getContentPane().add(contentPanel, BorderLayout.CENTER);
this.getContentPane().add(statusPanel, BorderLayout.SOUTH);
//加入地图
contentPanel.add(ui);
//加入计分
actionPanel.add(score);
//加入开始按钮
actionPanel.add(startButton);
startButton.setBorder(emptyBorder);
startButton.setIcon(imgStart);
startButton.addActionListener(this);
//加入刷新按钮
actionPanel.add(refreshButton);
refreshButton.setBorder(emptyBorder);
refreshButton.setIcon(imgRefresh);
refreshButton.addActionListener(this);
//加入提示按钮
actionPanel.add(hintButton);
hintButton.setBorder(emptyBorder);
hintButton.setIcon(imgHint);
hintButton.addActionListener(this);
//加入炸弹按钮
actionPanel.add(bombButton);
bombButton.setBorder(emptyBorder);
bombButton.setIcon(imgBomb);
bombButton.addActionListener(this);
//加入自动演示
actionPanel.add(demoButton);
demoButton.setBorder(emptyBorder);
demoButton.setIcon(imgDemo);
demoButton.addActionListener(this);
//加入设置
toolBar.add(setupButton);
setupButton.setBorder(emptyBorder);
setupButton.setIcon(imgSetup);
setupButton.addActionListener(this);
//加入帮助
toolBar.add(helpButton);
helpButton.setBorder(emptyBorder);
helpButton.setIcon(imgHelp);
helpButton.addActionListener(this);
//加入关于
toolBar.add(aboutButton);
aboutButton.setBorder(emptyBorder);
aboutButton.setIcon(imgAbout);
aboutButton.addActionListener(this);
//加入时钟
actionPanel.add(clock);
//加入状态栏
statusPanel.add(statusField, BorderLayout.CENTER);
statusField.setBorder(unSelected);
statusField.setEditable(false);
statusField.setForeground(Color.white);
statusField.setBackground(DarkColor);
//加入发送按钮
statusPanel.add(goTop10, BorderLayout.EAST);
goTop10.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0));
goTop10.setForeground(Color.white);
goTop10.s
没有合适的资源?快使用搜索试试~ 我知道了~
资源推荐
资源详情
资源评论
收起资源包目录
宝石连连看游戏.rar (83个子文件)
宝石连连看游戏
打包发布
Kyodai.jar 543KB
Kyodai.bat 21B
kyodai.ini 86B
源文件
sound
select.wav 3KB
bomb.wav 43KB
earse.wav 61KB
bg.mid 30KB
bg2.mid 499B
refresh.wav 213KB
hint.wav 76KB
images
35.gif 1KB
15.gif 2KB
28.gif 2KB
1.gif 2KB
31.gif 2KB
me.gif 12KB
25.gif 2KB
36.gif 2KB
32.gif 2KB
setup.gif 2KB
8.gif 2KB
16.gif 1KB
18.gif 2KB
41.gif 2KB
38.gif 2KB
19.gif 2KB
22.gif 2KB
bomb.gif 2KB
26.gif 2KB
about.gif 992B
21.gif 2KB
12.gif 2KB
20.gif 1KB
start.gif 2KB
11.gif 2KB
10.gif 2KB
39.gif 2KB
refresh.gif 2KB
hint.gif 2KB
7.gif 2KB
37.gif 2KB
27.gif 2KB
42.gif 2KB
34.gif 2KB
17.gif 2KB
29.gif 2KB
4.gif 2KB
3.gif 2KB
24.gif 2KB
demo.gif 2KB
13.gif 2KB
5.gif 2KB
40.gif 2KB
2.gif 2KB
dots.gif 110B
kyodai16.gif 996B
30.gif 2KB
6.gif 2KB
14.gif 2KB
23.gif 1KB
9.gif 2KB
cursor.gif 982B
help.gif 1KB
33.gif 2KB
MANIFEST.MF 52B
kyodai
ClockAnimate.java 2KB
Kyodai.java 10KB
Sound.java 2KB
Music.java 2KB
map
AnimateDelete.java 4KB
Map.java 6KB
Line.java 300B
MapUI.java 9KB
Top10.java 3KB
topbar
SetupDialog.java 8KB
AboutDialog.java 3KB
SetupDialog.java.bak 8KB
HelpDialog.java 3KB
Setting.java 3KB
ScoreAnimate.java 2KB
doc
help.htm 1KB
Top.htm 965B
help.htm.bak 1KB
共 83 条
- 1
资源评论
- freddyfei572012-12-19还可以 谢谢~~~可不是我需要的
jfxxzy
- 粉丝: 1
- 资源: 7
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功