java连连看程序设计报告_毕业论文设计 JAVA游戏程序设计--连连看游戏设计

该文详细介绍了使用Java编程实现连连看游戏的过程,包括界面设计、随机图片生成、消除规则、画线算法以及游戏玩法的实现。重点讨论了如何确保每种图片数量为偶数、判断鼠标点击的图片是否可消除以及连线逻辑。此外,文中还涵盖了游戏的开始、暂停、求助、重置等功能的实现,增强了游戏的趣味性和挑战性。
摘要由CSDN通过智能技术生成

内容介绍

摘 要

本文用Java来设计与实现简单的连连看游戏的基本功能,玩家可以在游戏区域中通过鼠标来选取相同的两个图片,采用特定的消除规则对它们进行消除的操作,当游戏区域中的所有图片对都被消除后玩家即可胜利。文章对该游戏的算法以及游戏图片的绘制、画线等进行详细的介绍,实现比较简单。文章重点内容是:如何设置整个游戏的界面,如何控制连连看游戏中随机图片的生成且每种图片必须为偶数个。游戏开始后,判断鼠标两次点击的图片能否消去。如何画出一条线连接这两个相同的图片。最后能够实现简单的不同的玩法和闯关的功能,增强游戏的趣味兴。

[关键词] 连连看 Java 游戏 重点内容

Abstract

Use java for this design and implementation of the simplest lianliankan games, players can the basic functions in the region through the mouse to choose two identical images, in particular the rules for them to be eliminated. when the area in all the pictures to all the players can be eliminated. on the game of the algorithm and a drawn game, drawing a line waiting for detailed information, the relatively simple.The article is focused on the issues : for placing the entire game interface , how to control was a series of view game generated and random photo in every kind of photo must even-numbered . After the start of the game , can judge the photo of the mouse two hits.How to draw a line linking these two identical photo . Final simple different can be achieved and break through the barrier of functional , enhance the taste xing of the game .

[Key words ] Linking up , Java , game Key contents

目 录

1 引言……………………………………………………………………………….

1.1游戏介绍……………………………………………………………………………

1.2设计目的……………………………………………………………………….

1.3主要问题……………………………………………………………………….

1.4开发环境…………………………………………………………………..

2 需求分析…………………………………………………………………………

3 可行性研究…………………………………………………………………….

4 功能模块设计…………………………………………………………………………..

4.1总体模块………………………………………………………………….

4.2基本类的UML图…………………………………………………………

5 详细设计…………………………………………………………………

5.1界面设计………………………………………………………………

5.11开始按钮………………………………………………………

5.12暂定按钮……………………………………………………….

5.13求助按钮………………………………………………………

5.14结束按钮………………………………………………………..

5.15重排按钮………………………………………………………..

5.16标签……………………………………………………………….

5.17记分器…………………………………………………………….

5.2画图分析…………………………………………………………………….

5.3偶数个图片、重排分析与设计………………………………………

5.4消去算法的分析与设计………………………………………………….

5.41初始化工作……………………………………….

5.42水平判断………………………………………..

5.43垂直判断………………………………………

5.5画线的分析与设计………………………………………………………..

5.6鼠标单击事件分析与设计………………………………………………

5.7帮助算法分析与设计………………………………………………………

5.8不同玩法的分析分析和设计…………………………………………..

6 编码…………………………………………………………………………..

7 测试………………………………………………………………………………………….

7.1限时功能的测试…………………………………………………………………

7.2画线测试……………………………………………………………………….

7.3图形的移动测试…………………………………………………………………

7.4消除测试…………………………………………………………………………….

8总结…………………………………………………………………………………….

参考文献………………………………………………………………………………….

附录………………………………………………………………………………………

  • 1
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
java连连看代码 import java.awt.*; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.util.ArrayList; import javax.swing.*; public class Game extends JFrame{ private int num[][]; //实现数组 private JButton gamebutton[][]; //游戏Button组 private Container cont; //内容面板 private JLabel timelabel; //时间标签 private JButton play; //开始游戏按钮 private JButton exit; //退出按钮 private JButton replay; //重新开始按钮 private JButton back; //返回主界面按钮 private JComboBox choice;//游戏等级 private JButton chongle; //游戏按钮重列 private JPanel gamepanel; //游戏按钮面板 private JPanel panel; //开始游戏面板 private int time=0; //时间记录 private Time T; //记时线程 private Thread t=new Thread(T); //记时线程 private int shu=1; //记录获取游戏按钮事件的个数 private int x=0,y=0,a=0,b=0;//按钮的坐标 private JButton button1=null,button2=null;//点击了的按钮 private boolean can;//能否消除 private int lvx,lvy; //游戏等级数组标列数 private int framex,framey; //框架大小 private int again=1;//记录重列次数 public Game(){ itincomponent(); } private void itincomponent(){ //设置面板属性 if(cont!=null) cont.removeAll(); this.setSize(500, 500); this.setLocationRelativeTo(null); //获取内容面板 cont=this.getContentPane(); //开始和退出按钮 panel=new JPanel(); play=new JButton("开始游戏"); choice=new JComboBox(); choice.addItem("低级"); choice.addItem("中级"); choice.addItem("高级"); choice.setSelectedItem("低级"); exit=new JButton("退出游戏"); panel.add(choice); panel.add(play); panel.add(exit); cont.add(panel,"South"); exit.addActionListener(new Exit());//结束事件监听 play.addActionListener(new Play());//开始事件监听 this.setResizable(false); this.setVisible(true); this.setDefaultCloseOperation(EXIT_ON_CLOSE); } ////获得新的面板 private void p(){ //设置面板属性 this.setSize(framex, framey); this.setLocationRelativeTo(null); //获取内容面板 cont=this.getContentPane(); //开始和退出按钮 panel=new JPanel(); exit=new JButton("退出游戏"); replay=new JButton("重新开始"); back=new JButton("返回主界面"); chongle=new JButton("重列"); panel.add(chongle); panel.add(replay); panel.add(exit); panel.add(back); cont.add(panel,"South"); exit.addActionListener(new Exit());//结束事件监听 replay.addActionListener(new Playbutton());//重新开始事件监听 back.addActionListener(new Back());//返回主界面事件监听 chongle.addActionListener(new Chongle());//重列事件监听 //时间面板 timelabel=new JLabel("游戏时间:"+time+"s",JLabel.CENTER); cont.add(timelabel,"North"); //生成游戏操作面板 gamepanel=new JPanel(); gamepanel.setLayout(new GridLayout(lvx,lvy,3,3)); //设置为表格布局 for (int i = 0; i < lvx; i++) { for (int j = 0; j <lvy; j++) { if(gamebutton[i][j].isVisible()){ gamebutton[i][j].setIcon(new ImageIcon(num[i][j]+".jpg")); } gamepanel.add(gamebutton[i][j]); gamebutton[i][j].addActionListener(new Gamebutton()); } } cont.add(gamepanel, "Center"); this.setResizable(false); this.setVisible(true); this.setDefaultCloseOperation(EXIT_ON_CLOSE); }
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值