import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import maze.eng.manage;
import maze.eng.mapBuilderChilderOne;
import maze.eng.mapBuilderChilderTwo;
import maze.eng.mapBuilderFarther;
import maze.eng.walkControl;
public class Main extends JFrame
{
int keepGUI = 19;
int b = (keepGUI - 2) * 2 + 2;
private JLabel[][] area = new JLabel[b][b];
int xContStar;
int yContStar;
int xContEnd;
int yContEnd;
mapBuilderFarther builderKeeper;
manage theManage;
ImageIcon iconsOne = new ImageIcon(getClass().getResource("1.jpg"));
ImageIcon iconsTwo = new ImageIcon(getClass().getResource("2.jpg"));
ImageIcon iconsThr = new ImageIcon(getClass().getResource("3.jpg"));
ImageIcon iconsFou = new ImageIcon(getClass().getResource("4.jpg"));
private JMenuItem jmiOpen = new JMenuItem("新游戏");
private JMenuItem jmiClose = new JMenuItem("退出");
private JMenuItem chooseOne = new JMenuItem("简单");
private JMenuItem chooseTwo = new JMenuItem("中等");
private JMenuItem chooseThr = new JMenuItem("困难");
private JMenuItem chooseFou = new JMenuItem("模式1");
private JMenuItem chooseFiv = new JMenuItem("模式2");
public Main(String title)
{
super(title);
xContStar = 0;
yContStar = 0;
xContEnd = 0;
yContEnd = 0;
builderKeeper = new mapBuilderChilderOne();
final walkControl control = new walkControl();
JMenu JmenuOne = new JMenu("开始");
JmenuOne.add(jmiOpen);
JmenuOne.add(jmiClose);
JMenu JmenuTwo = new JMenu("难度");
JmenuTwo.add(chooseOne);
JmenuTwo.add(chooseTwo);
JmenuTwo.add(chooseThr);
JmenuTwo.add(chooseFou);
JmenuTwo.add(chooseFiv);
JMenuBar jmenuBar = new JMenuBar();
jmenuBar.add(JmenuOne);
jmenuBar.add(JmenuTwo);
theManage = builderKeeper.getMap(b);
final JPanel contentPane = new JPanel();
contentPane.setLayout(new GridLayout(keepGUI,keepGUI));
final JPanel contentButton = new JPanel();
contentButton.setLayout(new BorderLayout());
contentButton.add(jmenuBar,BorderLayout.WEST);
Container contentPaneAll = getContentPane();
int count = 0;
contentPaneAll.add(contentPane, BorderLayout.CENTER);
contentPaneAll.add(contentButton, BorderLayout.NORTH);
addKeyListener(new KeyAdapter()
{
public void keyPressed(KeyEvent ev)
{
int key = ev.getKeyCode();
control.walkCont(key, theManage);
printWhe();
int cI = 0;
int cJ = 0;
for(int i = xContStar; i < xContEnd; i++)
{
cJ = 0;
for(int j = yContStar; j < yContEnd; j++)
{
if(theManage.getManage(i + 1, j + 1) == '1')
{
area[cI][cJ].setIcon(iconsOne);
}
else if(theManage.getManage(i + 1, j + 1) == '2')
{
area[cI][cJ].setIcon(iconsTwo);
}
else if(theManage.getManage(i + 1, j + 1) == '3')
{
area[cI][cJ].setIcon(iconsThr);
}
else if(theManage.getManage(i + 1, j + 1) == '4')
{
area[cI][cJ].setIcon(iconsFou);
}
cJ++;
}
cI++;
}
}
});
chooseOne.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
b = keepGUI;
theManage = builderKeeper.getMap(b);
xContStar = 0;
yContStar = 0;
xContEnd = 0;
yContEnd = 0;
for(int i = 0; i < keepGUI; i++)
{
for(int j = 0; j < keepGUI; j++)
{
if(theManage.getManage(i + 1, j + 1) == '1')
{
area[i][j].setIcon(iconsOne);
}
else if(theManage.getManage(i + 1, j + 1) == '2')
{
area[i][j].setIcon(iconsTwo);
}
else if(theManage.getManage(i + 1, j + 1) == '3')
{
area[i][j].setIcon(iconsThr);
}
else if(theManage.getManage(i + 1, j + 1) == '4')
{
area[i][j].setIcon(iconsFou);
}
}
}
}
});
chooseTwo.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
b = (keepGUI - 2) * 2 + 2;
theManage = builderKeeper.getMap(b);
xContStar = 0;
yContStar = 0;
xContEnd = 0;
yContEnd = 0;
for(int i = 0; i < keepGUI; i++)
{
for(int j = 0; j < keepGUI; j++)
{
if(theManage.getManage(i + 1, j + 1) == '1')
{
area[i][j].setIcon(iconsOne);
}
else if(theManage.getManage(i + 1, j + 1) == '2')
{
area[i][j].setIcon(iconsTwo);
}
else if(theManage.getManage(i + 1, j + 1) == '3')
{
area[i][j].setIcon(iconsThr);
}
else if(theManage.getManage(i + 1, j + 1) == '4')
{
area[i][j].setIcon(iconsFou);
}
}
}
}
});
chooseThr.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
b = (keepGUI - 2) * 6 + 2;
theManage = builderKeeper.getMap(b);
xContStar = 0;
yContStar = 0;
xContEnd = 0;
yContEnd = 0;
for(int i = 0; i < keepGUI; i++)
{
for(int j = 0; j < keepGUI; j++)
{
if(theManage.getManage(i + 1, j + 1) == '1')
{
area[i][j].setIcon(iconsOne);
}
else if(theManage.getManage(i + 1, j + 1) == '2')
{
area[i][j].setIcon(iconsTwo);
}
else if(theManage.getManage(i + 1, j + 1) == '3')
{
area[i][j].setIcon(iconsThr);
}
else if(theManage.getManage(i + 1, j + 1) == '4')
{
qingtianJAVA
- 粉丝: 0
- 资源: 1
最新资源
- java毕设项目之ssm基于Vue.js的在线购物系统的设计与实现+vue(完整前后端+说明文档+mysql+lw).zip
- java毕设项目之ssm汽车养护管理系统+jsp(完整前后端+说明文档+mysql+lw).zip
- java毕设项目之ssm简易版营业厅宽带系统+jsp(完整前后端+说明文档+mysql+lw).zip
- java毕设项目之ssm绿色农产品推广应用网站+vue(完整前后端+说明文档+mysql+lw).zip
- java毕设项目之ssm人事管理信息系统+jsp(完整前后端+说明文档+mysql+lw).zip
- 自考04741《计算机网络原理》试题及答案2016-2018
- java毕设项目之ssm社区管理与服务的设计与实现+jsp(完整前后端+说明文档+mysql+lw).zip
- java毕设项目之ssm社区文化宣传网站+jsp(完整前后端+说明文档+mysql+lw).zip
- java毕设项目之ssm实验室耗材管理系统设计与实现+jsp(完整前后端+说明文档+mysql+lw).zip
- java毕设项目之ssm网络游戏公司官方平台设计与实现+jsp(完整前后端+说明文档+mysql+lw).zip
- java毕设项目之ssm蜀都天香酒楼的网站设计与实现+jsp(完整前后端+说明文档+mysql+lw).zip
- java毕设项目之ssm网上医院预约挂号系统+jsp(完整前后端+说明文档+mysql+lw).zip
- java毕设项目之ssm网上花店设计+vue(完整前后端+说明文档+mysql+lw).zip
- java毕设项目之ssm网上服装销售系统+jsp(完整前后端+说明文档+mysql+lw).zip
- java毕设项目之ssm小型企业办公自动化系统的设计和开发+vue(完整前后端+说明文档+mysql+lw).zip
- java毕设项目之ssm物流管理系统设计与实现+jsp(完整前后端+说明文档+mysql+lw).zip
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈