连连看java程序-论文

上传人:第*** 文档编号:35540436 上传时间:2018-03-17 格式:DOC 页数:60 大小:68.80KB
返回 下载 相关 举报
连连看java程序-论文_第1页
第1页 / 共60页
连连看java程序-论文_第2页
第2页 / 共60页
连连看java程序-论文_第3页
第3页 / 共60页
连连看java程序-论文_第4页
第4页 / 共60页
连连看java程序-论文_第5页
第5页 / 共60页
点击查看更多>>
资源描述

《连连看java程序-论文》由会员分享,可在线阅读,更多相关《连连看java程序-论文(60页珍藏版)》请在金锄头文库上搜索。

1、连连看连连看javajava程序程序- -论文论文连连看java程序package kyodai.map;import java.awt.*;import javax.swing.*;import kyodai.*;/* 消除连连看方块的类*/ public class AnimateDelete implements Runnable static JButton dots;static long delay = 20l;int array = new int44; /最大距离只可能为2行1列private int count = 0;private volatile Thread thre

2、ad;public AnimateDelete(JButton dots) this.dots = dots;array = new int0;/* 初始化*/public AnimateDelete(int direct, Point a, Point b) initArray();calcTwoPoint(direct, a, b);start();/* direct 方向* 1表示a, b在同一直线上,b, c在同一竖线上;* 0表示a, b在同一竖线上,b, c在同一直线上*/public AnimateDelete(int direct, Point a, Point b, Poin

3、t c) initArray();if (direct = 1) /先横后竖calcTwoPoint(1, a, b);count-;calcTwoPoint(0, b, c);else calcTwoPoint(0, a, b);count-;calcTwoPoint(1, b, c);start();/* direct 方向* 1表示a, b为横线,b, c为竖线, c, d为横线* 0表示a, b为竖线,b, c为横线,c, d为竖线*/public AnimateDelete(int direct, Point a, Point b, Point c, Point d) initArr

4、ay();if (direct = 1) /横、竖、横方式处理calcTwoPoint(1, a, b);count-;calcTwoPoint(0, b, c);count-;calcTwoPoint(1, c, d);else /竖、横、竖方式处理calcTwoPoint(0, a, b);count-;calcTwoPoint(1, b, c);count-;calcTwoPoint(0, c, d);start();/* 计算消除的两点*/private void calcTwoPoint(int direct, Point a, Point b) int offset = 0;if

5、(direct = 1) /横向连接if (a.y b.y) /a点向b点是从右向左在水平线上消除for (int y = a.y; y = b.y; y-) offset = a.x * Setting.COLUMN + y;arraycount = offset;count+;else /a点向b点是从左向右在水平线上消除for (int y = a.y; y b.x) /a点向b点是从下向上垂直消除for (int x = a.x; x = b.x; x-) offset = x * Setting.COLUMN + a.y;arraycount = offset;count+;else

6、 /a点向b点是从上向下垂直消除for (int x = a.x; x 0; i-)int j = random.nextInt(i);int temp = arrayj;arrayj = arrayi - 1;arrayi - 1 = temp;public void earse(Point a, Point b)mapa.xa.y = 0;mapb.xb.y = 0;restBlock -= 2;public int getCount()return restBlock 0)tempcount = maprowcol;count+;random(temp);count = 0;for(in

7、t row = 0; row 0)maprowcol = tempcount;count+;private boolean horizon(Point a, Point b, boolean recorder)if(a.x = b.x int x_start = a.y = 0; y-)if(mapa.xy = 0 for(int y = a.y; y = 0; x-)if(mapxa.y = 0 for(int x = a.x; x 0) dotsindex.setIcon(Kyodai.BlocksIconmap.getMap()rowcol - 1);dotsindex.setEnabl

8、ed(true);else dotsindex.setIcon(null);dotsindex.setEnabled(false);public void repaint(Graphics g) paint();/* 判断当前是否已经没有可消除的方块*/private boolean validMap(Point a) if (map.getCount() = 0) return true;Line line = new Line(0, new Point(), new Point();map.setTest(true); /只测试line = map.findNext(a);int offs

9、et = 0;if (line.direct = 1) /找到了可消除的return true;else return false;/* 更新当前显示的分数*/private void showScore(int l, int c) if (scoreAnimate = null) return;scoreAnimate.setScore(l, c);/* 刷新当前的排列方式*/public void refresh() if (!isPlaying) /不在游戏中,返回return;if (map.getCount() = 0) Kyodai.showHint(“还刷,都没了!“);if (

10、Setting.Sound = 1) new Sound(Sound.REFRESH);if (validMap(new Point( -1, -1) score -= Setting.freshScore;showScore(score - 1, score);else showScore(score, score + Setting.freshScore);score += Setting.freshScore;score -= Setting.freshScore;showScore(score - 1, score);map.refresh();paint();/* 消除两个点*/vo

11、id earse(Point a, Point b) /paint();int offset;offset = a.x * Setting.COLUMN + a.y;dotsoffset.setIcon(null);dotsoffset.setEnabled(false);offset = b.x * Setting.COLUMN + b.y;dotsoffset.setIcon(null);dotsoffset.setEnabled(false);/如果地图清除完成,关闭if (map.getCount() = 0) int remainTime = limitTime - clockAni

12、mate.getUsedTime();message(“剩余时间 = “ + remainTime);if (remainTime 0) showScore(score, score + remainTime * Setting.timeScore);score += remainTime * Setting.timeScore;isPlaying = false;stop();Kyodai.showHint(“时间+ “ + remainTime * Setting.timeScore + “,想看看你的排名吗?“);goTop10.setEnabled(true);else /test1(

13、map.getDeleteArray();/* 自动寻找最佳答案*/public void findNext(Point a) if (!isPlaying) /不在游戏中,返回return;if (map.getCount() = 0) Kyodai.showHint(“你找昏了头吧,没了!“);return;Line line = new Line(0, new Point(), new Point();map.setTest(true); /告诉map当前只是测试,并不需要进行删除动画line = map.findNext(a);int offset = 0;if (line.direc

14、t = 1) /找到了可消除的if (Setting.Sound = 1) new Sound(Sound.HINT);offset = line.a.x * Setting.COLUMN + line.a.y;dotsoffset.setBorder(Kyodai.Hint);offset = line.b.x * Setting.COLUMN + line.b.y;dotsoffset.setBorder(Kyodai.Hint);score -= Setting.hintScore;showScore(score - 1, score);else Kyodai.showHint(“找不到

15、,请刷新“);/* 自动找出并消除地图上的两个点*/public boolean bomb(Point a, boolean showMessage) if (!isPlaying) /不在游戏中,返回return false;if (map.getCount() = 0) Kyodai.showHint(“你炸昏了头吧,没了!“);return false;Line line = new Line(0, new Point(), new Point();map.setTest(false);line = map.findNext(a);int offset = 0;if (line.direct = 1) /找到了可消除的if (Setting.Sound = 1) new Sound(Sound.BOMB);offset = line.a.x * Setting.COLUMN + line.a.y;dotsoffset.setBorder(Kyodai.unSelected);offset = line.b.x * Setting.COLUMN + line.b.y;dotsoffset.setBo

展开阅读全文
相关资源
相关搜索

当前位置:首页 > 建筑/环境 > 工程造价

电脑版 |金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号