当前位置:首页 » 课程大全 » 连连看游戏课程设计

连连看游戏课程设计

发布时间: 2021-02-05 07:11:34

⑴ 连连看游戏设计与实现

import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
public class lianliankan implements ActionListener
{
JFrame mainFrame; //主面板
Container thisContainer;
JPanel centerPanel,southPanel,northPanel; //子面板
JButton diamondsButton[][] = new JButton[6][5];//游戏按钮数组
JButton exitButton,resetButton,newlyButton; //退出,重列,重新开始按钮
JLabel fractionLable=new JLabel("0"); //分数标签
JButton firstButton,secondButton; //分别记录两次被选中的按钮
int grid[][] = new int[8][7];//储存游戏按钮位置
static boolean pressInformation=false; //判断是否有按钮被选中
int x0=0,y0=0,x=0,y=0,fristMsg=0,secondMsg=0,validateLV; //游戏按钮的位置坐标
int i,j,k,n;//消除方法控制
public void init(){
mainFrame=new JFrame("JKJ连连看");
thisContainer = mainFrame.getContentPane();
thisContainer.setLayout(new BorderLayout());
centerPanel=new JPanel();
southPanel=new JPanel();
northPanel=new JPanel();
thisContainer.add(centerPanel,"Center");
thisContainer.add(southPanel,"South");
thisContainer.add(northPanel,"North");
centerPanel.setLayout(new GridLayout(6,5));
for(int cols = 0;cols < 6;cols++){
for(int rows = 0;rows < 5;rows++ ){
diamondsButton[cols][rows]=new JButton(String.valueOf(grid[cols+1][rows+1]));
diamondsButton[cols][rows].addActionListener(this);
centerPanel.add(diamondsButton[cols][rows]);
}
}
exitButton=new JButton("退出");
exitButton.addActionListener(this);
resetButton=new JButton("重列");
resetButton.addActionListener(this);
newlyButton=new JButton("再来一局");
newlyButton.addActionListener(this);
southPanel.add(exitButton);
southPanel.add(resetButton);
southPanel.add(newlyButton);
fractionLable.setText(String.valueOf(Integer.parseInt(fractionLable.getText())));
northPanel.add(fractionLable);
mainFrame.setBounds(280,100,500,450);
mainFrame.setVisible(true);
}
public void randomBuild() {
int randoms,cols,rows;
for(int twins=1;twins<=15;twins++) {
randoms=(int)(Math.random()*25+1);
for(int alike=1;alike<=2;alike++) {
cols=(int)(Math.random()*6+1);
rows=(int)(Math.random()*5+1);
while(grid[cols][rows]!=0) {
cols=(int)(Math.random()*6+1);
rows=(int)(Math.random()*5+1);
}
this.grid[cols][rows]=randoms;
}
}
}
public void fraction(){
fractionLable.setText(String.valueOf(Integer.parseInt(fractionLable.getText())+100));
}
public void reload() {
int save[] = new int[30];
int n=0,cols,rows;
int grid[][]= new int[8][7];
for(int i=0;i<=6;i++) {
for(int j=0;j<=5;j++) {
if(this.grid[i][j]!=0) {
save[n]=this.grid[i][j];
n++;
}
}
}
n=n-1;
this.grid=grid;
while(n>=0) {
cols=(int)(Math.random()*6+1);
rows=(int)(Math.random()*5+1);
while(grid[cols][rows]!=0) {
cols=(int)(Math.random()*6+1);
rows=(int)(Math.random()*5+1);
}
this.grid[cols][rows]=save[n];
n--;
}
mainFrame.setVisible(false);
pressInformation=false; //这里一定要将按钮点击信息归为初始
init();
for(int i = 0;i < 6;i++){
for(int j = 0;j < 5;j++ ){
if(grid[i+1][j+1]==0)
diamondsButton[i][j].setVisible(false);
}
}
}
public void estimateEven(int placeX,int placeY,JButton bz) {
if(pressInformation==false) {
x=placeX;
y=placeY;
secondMsg=grid[x][y];
secondButton=bz;
pressInformation=true;
}
else {
x0=x;
y0=y;
fristMsg=secondMsg;
firstButton=secondButton;
x=placeX;
y=placeY;
secondMsg=grid[x][y];
secondButton=bz;
if(fristMsg==secondMsg && secondButton!=firstButton){
xiao();
}
}
}
public void xiao() { //相同的情况下能不能消去。仔细分析,不一条条注释
if((x0==x &&(y0==y+1||y0==y-1)) || ((x0==x+1||x0==x-1)&&(y0==y))){ //判断是否相邻
remove();
}
else{
for (j=0;j<7;j++ ) {
if (grid[x0][j]==0){ //判断第一个按钮同行哪个按钮为空
if (y>j) { //如果第二个按钮的Y坐标大于空按钮的Y坐标说明第一按钮在第二按钮左边
for (i=y-1;i>=j;i-- ){ //判断第二按钮左侧直到第一按钮中间有没有按钮
if (grid[x][i]!=0) {
k=0;
break;
}
else{ k=1; } //K=1说明通过了第一次验证
}
if (k==1) {
linePassOne();
}
}
if (y<j){ //如果第二个按钮的Y坐标小于空按钮的Y坐标说明第一按钮在第二按钮右边
for (i=y+1;i<=j ;i++ ){ //判断第二按钮左侧直到第一按钮中间有没有按钮
if (grid[x][i]!=0){
k=0;
break;
}
else { k=1; }
}
if (k==1){
linePassOne();
}
}
if (y==j ) {
linePassOne();
}
}
if (k==2) {
if (x0==x) {
remove();
}
if (x0<x) {
for (n=x0;n<=x-1;n++ ) {
if (grid[n][j]!=0) {
k=0;
break;
}
if(grid[n][j]==0 && n==x-1) {
remove();
}
}
}
if (x0>x) {
for (n=x0;n>=x+1 ;n-- ) {
if (grid[n][j]!=0) {
k=0;
break;
}
if(grid[n][j]==0 && n==x+1) {
remove();
}
}
}
}
}
for (i=0;i<8;i++ ) { //列
if (grid[i][y0]==0) {
if (x>i) {
for (j=x-1;j>=i ;j-- ) {
if (grid[j][y]!=0) {
k=0;
break;
}
else { k=1; }
}
if (k==1) {
rowPassOne();
}
}
if (x<i) {
for (j=x+1;j<=i;j++ ) {
if (grid[j][y]!=0) {
k=0;
break;
}
else { k=1; }
}
if (k==1) {
rowPassOne();
}
}
if (x==i) {
rowPassOne();
}
}
if (k==2){
if (y0==y) {
remove();
}
if (y0<y) {
for (n=y0;n<=y-1 ;n++ ) {
if (grid[i][n]!=0) {
k=0;
break;
}
if(grid[i][n]==0 && n==y-1) {
remove();
}
}
}
if (y0>y) {
for (n=y0;n>=y+1 ;n--) {
if (grid[i][n]!=0) {
k=0;
break;
}
if(grid[i][n]==0 && n==y+1) {
remove();
}
}
}
}
}
}
}
public void linePassOne(){
if (y0>j){ //第一按钮同行空按钮在左边
for (i=y0-1;i>=j ;i-- ){ //判断第一按钮同左侧空按钮之间有没按钮
if (grid[x0][i]!=0) {
k=0;
break;
}
else { k=2; } //K=2说明通过了第二次验证
}
}
if (y0<j){ //第一按钮同行空按钮在与第二按钮之间
for (i=y0+1;i<=j ;i++){
if (grid[x0][i]!=0) {
k=0;
break;
}
else{ k=2; }
}
}
}
public void rowPassOne(){
if (x0>i) {
for (j=x0-1;j>=i ;j-- ) {
if (grid[j][y0]!=0) {
k=0;
break;
}
else { k=2; }
}
}
if (x0<i) {
for (j=x0+1;j<=i ;j++ ) {
if (grid[j][y0]!=0) {
k=0;
break;
}
else { k=2; }
}
}
}
public void remove(){
firstButton.setVisible(false);
secondButton.setVisible(false);
fraction();
pressInformation=false;
k=0;
grid[x0][y0]=0;
grid[x][y]=0;
}
public void actionPerformed(ActionEvent e) {
if(e.getSource()==newlyButton){
int grid[][] = new int[8][7];
this.grid = grid;
randomBuild();
mainFrame.setVisible(false);
pressInformation=false;
init();
}
if(e.getSource()==exitButton)
System.exit(0);
if(e.getSource()==resetButton)
reload();
for(int cols = 0;cols < 6;cols++){
for(int rows = 0;rows < 5;rows++ ){
if(e.getSource()==diamondsButton[cols][rows])
estimateEven(cols+1,rows+1,diamondsButton[cols][rows]);
}
}
}
public static void main(String[] args) {
lianliankan llk = new lianliankan();
llk.randomBuild();
llk.init();
}
}

//old 998 lines
//new 318 lines

⑵ 连连看游戏的编程思想

连连看
应该是能转2个弯吧<-这个不清楚
然后你从某个点出发向四周递归寻找。。最多只能转两次就行啦
主要思想是递归

⑶ c语言连连看课程设计求代码

你好!
这个课设有新意,矩阵是几乘几的呢

⑷ 我需要一篇基于java的连连看游戏设计与实现的毕业设计及论文

毕业后你打算干啥呢?
不如趁现在有时间好好练习下,碰到的问问先都学学。

⑸ 基于flash的连连看游戏的设计与实现怎么做啊

基于flash的连连看游戏的设计与实现这个其实不难的啊我可以帮你做的我的网名是:IT服务/aiq

⑹ 如何用JAVA 编写一个连连看游戏全程设计

刚试了。。测试通过。。
importjavax.swing.*;
importjava.awt.*;
importjava.awt.event.*;

publicclass LianLianKan implements ActionListener {
JFrame mainFrame; // 主面板
Container thisContainer;
JPanel centerPanel, southPanel, northPanel; //子面板
JButton diamondsButton[][] = newJButton[6][5];// 游戏按钮数组
JButton exitButton, resetButton, newlyButton;// 退出,重列,重新开始按钮
JLabel fractionLable = newJLabel("0"); // 分数标签
JButton firstButton, secondButton; // 分别记录两次被选中的按钮
// 储存游戏按钮位置(这里其实只要6行,5列。但是我们用了8行,7列。是等于在这个面板按钮的周围还围
//了一层是0的按钮,这样就可以实现靠近面板边缘的两个按钮可以消去)
int grid[][] = new int[8][7];
static boolean pressInformation = false; // 判断是否有按钮被选中
int x0 = 0, y0 = 0, x = 0, y = 0, fristMsg =0, secondMsg = 0, validateLV; // 游戏按钮的位置坐标
int i, j, k, n;// 消除方法控制

public void init() {
mainFrame = new JFrame("JKJ连连看");
thisContainer = mainFrame.getContentPane();
thisContainer.setLayout(new BorderLayout());
centerPanel = new JPanel();
southPanel = new JPanel();
northPanel = new JPanel();
thisContainer.add(centerPanel,"Center");
thisContainer.add(southPanel,"South");
thisContainer.add(northPanel,"North");
centerPanel.setLayout(new GridLayout(6, 5));

for (int cols = 0; cols < 6; cols++) {
for (int rows = 0; rows < 5; rows++) {
diamondsButton[cols][rows] = newJButton(String
.valueOf(grid[cols + 1][rows + 1]));
diamondsButton[cols][rows].addActionListener(this);
centerPanel.add(diamondsButton[cols][rows]);
}
}

exitButton = new JButton("退出");
exitButton.addActionListener(this);
resetButton = new JButton("重列");
resetButton.addActionListener(this);
newlyButton = new JButton("再来一局");
newlyButton.addActionListener(this);
southPanel.add(exitButton);
southPanel.add(resetButton);
southPanel.add(newlyButton);

fractionLable.setText(String.valueOf(Integer.parseInt(fractionLable
.getText())));
northPanel.add(fractionLable);

mainFrame.setBounds(280, 100, 500, 450);
mainFrame.setVisible(true);
mainFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}

public void randomBuild() {
int randoms, cols, rows;
for (int twins = 1; twins <= 15; twins++){//一共15对button,30个
randoms = (int) (Math.random() * 25 +1);//button上的数字
for (int alike = 1; alike <= 2; alike++){
cols = (int) (Math.random() * 6 + 1);
rows = (int) (Math.random() * 5 + 1);
while (grid[cols][rows] != 0) {//等于0说明这个空格有了button
cols = (int) (Math.random() * 6 + 1);
rows = (int) (Math.random() * 5 + 1);
}
this.grid[cols][rows] = randoms;
}
}
}

public void fraction() {
fractionLable.setText(String.valueOf(Integer.parseInt(fractionLable
.getText()) + 100));
}

public void reload() {
int save[] = new int[30];
int n = 0, cols, rows;
int grid[][] = new int[8][7];
for (int i = 0; i <= 6; i++) {
for (int j = 0; j <= 5; j++) {
if (this.grid[i][j] != 0) {
save[n] = this.grid[i][j];//记下每个button的数字
n++;//有几个没有消去的button
}
}
}
n = n - 1;
this.grid = grid;
while (n >= 0) {//把没有消去的button重新放一次
cols = (int) (Math.random() * 6 + 1);
rows = (int) (Math.random() * 5 + 1);
while (grid[cols][rows] != 0) {
cols = (int) (Math.random() * 6 + 1);
rows = (int) (Math.random() * 5 + 1);
}
this.grid[cols][rows] = save[n];
n--;
}

mainFrame.setVisible(false);
pressInformation = false; // 这里一定要将按钮点击信息归为初始
init();
for (int i = 0; i < 6; i++) {
for (int j = 0; j < 5; j++) {
if (grid[i + 1][j + 1] == 0)
diamondsButton[i][j].setVisible(false);
}
}
}

public void estimateEven(int placeX, intplaceY, JButton bz) {
if (pressInformation == false) {
x = placeX;
y = placeY;
secondMsg = grid[x][y];
secondButton = bz;
pressInformation = true;
} else {
x0 = x;
y0 = y;
fristMsg = secondMsg;
firstButton = secondButton;
x = placeX;
y = placeY;
secondMsg = grid[x][y];
secondButton = bz;
if (fristMsg == secondMsg &&secondButton != firstButton) {
xiao();
}
}
}

public void xiao() { // 相同的情况下能不能消去。仔细分析,不一条条注释
if ((x0 == x && (y0 == y + 1 || y0 ==y - 1))
|| ((x0 == x + 1 || x0 == x - 1) &&(y0 == y))) { // 判断是否相邻
remove();
} else {
for (j = 0; j < 7; j++) {
if (grid[x0][j] == 0) { // 判断和第一个按钮同行的哪个按钮为空
//如果找到一个为空的,就按列值的三种情况比较第二个按钮与空按钮的位置

if (y > j) {//第二个按钮在空按钮右边
for (i = y - 1; i >= j; i--) { //检测从第二个按钮横向左边到空格所在列为止是否全是空格
if (grid[x][i] != 0) {
k = 0;
break;//存在非空格的就退出,这一退出就不可能k==2了,所以就会到下而215行出同理的判断列
} else {
k = 1;
} // K=1说明全是空格通过了第一次验证,也就是从第二个按钮横向左边到空格所在列为止全是空格
}
if (k == 1) {
linePassOne();//进入第二次验证,也就是从第一个按钮到它同行的空格之间的空格判断
}
}

if (y < j) { // 第二个按钮在空按钮左边
for (i = y + 1; i <= j; i++) {//检测从第二个按钮横向右边到空格所在列为止是否全是空格
if (grid[x][i] != 0) {
k = 0;
break;
} else {
k = 1;
}
}
if (k == 1) {
linePassOne();
}
}

if (y == j) {//第二个按钮和空按钮同列
linePassOne();
}
}

//第三次检测,检测确定为空的第j列的那个按钮竖向到第二个按钮,看是不是有按钮
if (k == 2) {
if (x0 == x) {//第一,二按钮在同行
remove();
}

if (x0 < x) {//第一按钮在第二按钮下边
for (n = x0; n <= x - 1; n++) {//从空按钮竖向到第二个按钮所在行是否有按钮
if (grid[n][j] != 0) {
k= 0;
break;
}
//没有按钮,说明这条路经就通了
if (grid[n][j] == 0 && n == x -1) {
remove();
}
}
}

if (x0 > x) {//第一按钮在第二按钮上边
for (n = x0; n >= x + 1; n--) {
if (grid[n][j] != 0) {
k = 0;
break;
}
if (grid[n][j] == 0 && n == x +1) {
remove();
}
}
}
}

}//-------------------------------------for

//当上面的检测与第一个按钮同行的空格按钮失败后(不能找到与第二个按钮的相连路经),下面就执行
//检测与第一个按钮同列的空格按钮
for (i = 0; i < 8; i++) {
if (grid[i][y0] == 0) {// 判断和第一个按钮同列的哪个按钮为空
if (x > i) {//第二个按钮在这个空按钮的下面
for (j = x - 1; j >= i; j--) {
if (grid[j][y] != 0) {
k = 0;
break;
} else {
k = 1;
}
}
if (k == 1) {
rowPassOne();
}
}

if (x < i) {//第二个按钮在这个空按钮的上面
for (j = x + 1; j <= i; j++) {
if (grid[j][y] != 0) {
k = 0;
break;
} else {
k = 1;
}
}
if (k == 1) {
rowPassOne();
}
}

if (x == i) {//第二个按钮与这个空按钮同行
rowPassOne();
}
}

if (k == 2) {
if (y0 == y) {//第二个按钮与第一个按钮同列
remove();
}
if (y0 < y) {//第二个按钮在第一个按钮右边
for (n = y0; n <= y - 1; n++) {
if (grid[i][n] != 0) {
k = 0;
break;
}
if (grid[i][n] == 0 && n == y -1) {
remove();
}
}
}
if (y0 > y) {//第二个按钮在第一个按钮左边
for (n = y0; n >= y + 1; n--) {
if (grid[i][n] != 0) {
k = 0;
break;
}
if (grid[i][n] == 0 && n == y +1) {
remove();
}
}
}
}
}//--------------------------------for
}//-------------else
}//------------xiao

public void linePassOne() {
if (y0 > j) { // 第一按钮同行空按钮在左边
for (i = y0 - 1; i >= j; i--) { // 判断第一按钮同左侧空按钮之间有没按钮
if (grid[x0][i] != 0) {
k = 0;
break;
} else {
k = 2;
} // K=2说明通过了第二次验证
}
}

if (y0 < j) { // 第一按钮同行空按钮在右边
for (i = y0 + 1; i <= j; i++) {
if (grid[x0][i] != 0) {
k = 0;
break;
} else {
k = 2;
}
}
}
}

public void rowPassOne() {
if (x0 > i) {//第一个按钮在与它同列的那个空格按钮下面
for (j = x0 - 1; j >= i; j--) {
if (grid[j][y0] != 0) {
k = 0;
break;
} else {
k = 2;
}
}
}

if (x0 < i) {//第一个按钮在与它同列的那个空格按钮上面
for (j = x0 + 1; j <= i; j++) {
if (grid[j][y0] != 0) {
k = 0;
break;
} else {
k = 2;
}
}
}
}

public void remove() {
firstButton.setVisible(false);
secondButton.setVisible(false);
fraction();
pressInformation = false;
k = 0;
grid[x0][y0] = 0;
grid[x][y] = 0;
}

public void actionPerformed(ActionEvent e) {
if (e.getSource() == newlyButton) {
int grid[][] = new int[8][7];
this.grid = grid;
randomBuild();
mainFrame.setVisible(false);
pressInformation = false;
init();
}
if (e.getSource() == exitButton)
System.exit(0);
if (e.getSource() == resetButton)
reload();
for (int cols = 0; cols < 6; cols++) {
for (int rows = 0; rows < 5; rows++) {
if (e.getSource() ==diamondsButton[cols][rows])
estimateEven(cols + 1, rows + 1,diamondsButton[cols][rows]);
}
}
}

public static void main(String[] args) {
LianLianKan llk = new LianLianKan();
llk.randomBuild();
llk.init();
}
}

⑺ PPT课件中的连连看游戏是怎样制作的

http://wenku..com/link?url=vh6OYtYCSS2rR2se8BQsPsJ_-5e9g48wUUTsRKm
详细过程
此外,连连看开发工具还用Flash 8.0,
PPT:
现在计算机的大批量普及和多媒体技术的发展,运用多媒体上课已逐渐成为一种趋势。因而制作课件将成为当前各教师的一项基本功,各校也积极的、有针对性的开展一些多媒体课件制作的校本培训。 现在应用最广泛的多媒体课件形式是 PPT(用office PowerPoint 制作的幻灯片),由于它编辑、播放,各种操作简单易学。

⑻ 求flash制作连连看游戏的编程思路,谢谢。

在设计采用单机模式,当在规定的时间内消完全部的图片则当前关卡通过,若果在规定的时间内没能消完所有的图片则游戏结束,重新开始游戏。游戏规则是模仿普通的连连看游戏,主要是鼠标两次点击的图片是否消去的问题,当前,前提是点击两张相同的图片,若点击的是同一张图片或者两张不同的图片,则不予处理。在两张相同的图片用三根以内的直线连在一起,就可以消去;否则,不予处理。
游戏过程,如果玩家在一定的时间内消完则提示玩家胜利,并进入下一关。如果在一定的时间内图片没有消完则提示玩家时间到。每关以此类推。
一、 所有图片都是按约定好的种类数和在同一区域的重复次数随机出现,并且每张图片的出现次数为偶数,时间会有限制,每一关的图片数量或时间是不同的,这样就增加了游戏的难度。
二、 在同一区域中,图片出现的种类数和重复数是可以由玩家选择的,时间由游戏约定。不过玩家选择的种类数和重复次数必须是偶数才可以顺利完成游戏,否则游戏虽然可以正常运行,但无法完成游戏。
在一种方案中,由于出现的图像按种类数和重复数都由软件约定,这样就缺乏玩家自主选择的空间,只是在完系统已经是设定好的游戏,不能改变什么,这样就在无意中降低了玩家在游戏过程中的乐趣,最后致使玩家放弃继续玩下去。我们参考了网络上的连连看游戏,考虑到游戏的娱乐性。所以我们放弃第一种方案的设计思想,参考网络上流行的连连看游戏,设计第二种方案。
3主要问题
开始制作游戏时,主要解决问题有以下几个方面:如何设置整个游戏的界面;如何控制连连看游戏中随机图片的生成且每种图片必须为偶数个;游戏开始后,判断鼠标两次点击的图片能否消去,即图片是否相同且图片之间路径的判断;如何判断游戏是否结束以及输赢问题等。
3.4技术要求
本游戏软件可以再大多数计算机上运行,游戏中能正确判断鼠标两次点下的图片是否可以消去、能正确判断游戏是否已经结束。
4、 系统设计:
针对上面的需求分析,我们把整个软件分成两个模块:1、整体界面的设计和图片的随机生成;2、图片路径判断函数;
一下就是系统结构图:
4.1基本思路
4.1.1游戏画面问题的思路
画面,对于设计者来说,可以算是最简单的地方;但对于玩家,这却是最重要的,一般玩家不会关心你是怎么实现的,他所关心的是画面的美观,漂亮,是不是能让人赏心悦目。
.2获取图片位置的思路
通过数组从图片库随即获取规定个数的图片,随机分布在画布上。图片个数一定是个偶数个。
4.1.3 路径判断的思路
连连看所要求的是:
1:两个目标是相同的
2:两个目标之间连线的折点不超过两个。(连接线由x轴和y轴的平行线组成)那么分析一下连接的情况可以看到,一般分三种情况
1:直线相连2:一个折点3:两个折点;
可以发现,如果有折点,每个折点必定有且至少有一个坐标(x或者y)是和其中一个目标点是相同的,也就是说,折点必定在两个目标点所在的x方向或y方向的直线上。
所以设计思路就是:
假设目标点p1,p2,如果有两个折点分别在z1,z2那么,所要进行的是
1:如果验证p1,p2直线连线,则连接成立
2:搜索以p1,p2的x,y方向四条直线(可能某两条直线会重合)上的有限点,每次取两点作为z1,z2,验证p1到z1/z1到z2/z2到p2是否都能直线相连,是则连接成立。
4.1.4其他问题的思路
其他功能将在后面的具体各个部分的设计过程当中分别进行介绍。
4.2主界面的设计
由于这个程序的界面并不是很复杂,所以用到的控件也不多,主要核心内容还是后台的代码设计。图片的随机生成主要是用到一个random()函数将随机数赋值给flag[ ]数组中的每个元素,然后根据数组元素值,来显示图片。
4.2.1界面的设计
1、色彩上:总结人们的视觉习惯和色彩对眼睛的健康影响,决定对于画布采用黑色背景,神秘而大方;右边的控制区采用天蓝色,配合左边纯黑的背景,就像黑夜中的蓝天,纯洁而大方。
2、功能上:背景就是窗体,右侧是一个groupbox控件,用来放置控制按钮,下方是一个grogressbar控件,用来显示时间条。
4.2.2图片的随机生成
实现这个功能要分很多个步骤:
1. 程序运行时即载入游戏需要的N张图片,默认情况下图片种类是18,重复数是4(重复数必须是偶数),并且可以选择是否重列。通过一个循环,加载随机的选择N种图片。具体载入图片的代码如下:
private void InteBmp(int maxnum)
{
g_g=this.Creatphics();
for(int i=0;i<MAPWIDTH;i++)
for(int j=0;j<WAPHEIGHT;j++)
gamp[i,j]=0;
IniteRandoMap(ref gamp,maxnum);
AI=new Kernal(ref gmap);
for(int i=0;i<maxnum;i++)
{
ResourceManager rm=new ResourceManager(“LLK data”,Assembly,GetExecut ingAssembly() );
img[i]=(Image)rm.GetObject(i.ToString( )+”.bmp”);
//img[i]=(Image)Bitmap.FormFile(“Images\\”+(i+1). ToString( )+”.bmp”);
}
for(int i=0;i<6;i++)
{
//bombimg[i]=(Image)Bitmap.FromFile(“Image\\B”+(i++). ToString( )+”.bmp”);.
}
}
2. 当确认游戏开始时,通过画图过程完成图片生成,画图的过程代码如下
private bool CheckWin(ref int[,]map)
{
Bool Win=true;
for(int i=0;i0)
{
for(int i=0;i<multipic;i++)
{
Int xrandom=r.Next(19);
Int yrandom=r,Next(11);
If(map[xrandom,yrandom]==0)
{
map[xrandom,yrandom]=num;
}
else
i--;
}
num--;
}
}

private void FreshMap(ref int[,]map)
{
random r=new Random();
for (int i=0;i<MAPWIDTH;i++)
for(int j=0;j<MAPHEIGHT;j++)
{
if(gmap[i,j]!=0)
{
int x=r.Next(19);
int y=r.Next(11);
int temp=gmap[x,y];
gmap[x,y]=gmap[i,j]
gmap[i,j] =temp;
}
TransportMap(ref gmap);
}
private void TransportMap(ref int[,]map)
{
for (int i=0;i<MAPWIDTH;i++)
for(int j=0;j<MAPHEIGHT;j++)
{
AI.GiveMapValue(i,j,map[i,j]);
}
}
//在指定位置画指定图
private void Draw(Graphics g,Image scrImg,int PicxX,int PicV)
{
g.DrawImage(scrImg,new Point(PicX,PicV));
}

private void Forml_Paint(object sender,PaintEventArg e)
{
g_g.DrawLine(new.Pen(newSolidBrush(Color.DeepSkyBlue),5),0,11*34+5,19*34
,11*34+5);
If(bStart)
{
For(int i=0;i209)
{
MessageBox.Show(“游戏区域内最多只有209个孔,您选的数据太多!请重新选!”);
textBox1.Text=”18”;
textBox2.Text=”4”;
return;
}
IniteBmp(picnum);
If(bStart)
{
MessageBox.Show(“游戏已在运行!”);
return;
}
else
{
bStart=true;
this.Invalidate();
music.Play(“Sounds\\ bg-03.mid”);
}
}
重新实现代码如下:
Private void RefreshMap(ref int[,] map)
{
if ( int i=0;i<MAPWIDTH;i++)
for(int j<MAPHEIGHT;j++)
{
If(gmap[I,j]!=0)
{
Draw(g_g,img[gmap[I,j]-1],i*PICWIDTH,j*PICHEIGHT);
}
}
}
private void FreshMap(ref int[,] map)
{
Random r=new Random();
for(int i=0;j<MAPWIDTH;i++)
for(int j=0;j<MAPHEIGHT;j++)
{
if(gmap[I,j]!=0)
{
int x=r,Nex(19);
int y=r,Nex(11);
int temp=gmap[x,y];
gmap[x,y]=gmap[I,j];
gmap[I,j]=temp;
}
}
TransportMap(ref gmap);
}
Private void button2_Click(object sender,EventArgs e)
{
Refreshplayer.Play();
FreshMap(ref gmap);
This.Invalidate();
}
4.2.4得分设置
本游戏一改前人风格,采用全新计分方式,使人们在寻找相同图片的同时还注意路径的选择,更增加了游戏的趣味性,具体规则:直连得10分,一个拐点的20,两个拐点得40.用一个Label控件存储得分。
实现代码:
Switch(corner[2].X)
{
Case1;
Score+=20;//一个拐点加20;
g_g.DrawLine(pen,new Point(p1.X*31+15,p1.Y*34+17),new

Point(corner[0].X*31+15,corner[0],Y*34+17)),;
g_g.DrawLine(pen,new point(p2.X*31+15,p2.Y*34+17),new
Point(corner[0].X*31+15,corner[0],Y*34+17));
Thread.Sleep(100);
EraseBlock(g_g,p1,p2);

g_g.DrawLine(bkpen,new Point(p1.X*31+15,p1.Y*34+17)new
Point(corner[0].X*31+15,corner[0],Y*34+17);
g_g.DrawLine(bkpen,new Point(p1.X*31+15,p2.Y*34+170new
Point(corner[0].X*31+15,corner[0],Y*34+17);

break;
case 2;
score+=40;
Point[ ]ps={new Point(p1.X*31+15,p1.Y*34+17),new<br/> Point(corner[1].X*31+15,corner[1],Y*34+17),new<br/> Point(corner[0].X*31+15,corner[0],Y*34+17),newPoint(p2.X*31+15,p2.Y*34+17));<br/> g_g.DrawLine(pen,ps);<br/> Thread.Sleep(100);<br/> EraseBlock(g_g,p1,p2);<br/>//foreach(Point mp in ps)<br/>//{<br/> //MessageBox.Box.Show(“+mp.X.ToString( )+”,”+mp.Y.ToString( )+”)”));<br/>//}
break;
case 0;
score+=10;
g_g.DrawLine(pen,ps);Point(corner[0].X*31+15,corner[0],Y*34+17),newPoint(p2.X*31+15,p2.Y*34+17));
Thread.Sleep(100);
EraseBlock(g_g,p1,p2);
g_g.DrawLine(pen,ps);Point(corner[0].X*31+15,corner[0],Y*34+17),newPoint(p2.X*31+15,p2.Y*34+17));
break;
default:break;
}
//RefreshMap(ref gmap)
Label5.Text=score.ToString( );

参考:知道回答 #564313762

⑼ 连连看游戏设计与实现论文怎么答辩

连连看游戏设计与实现论简\
通常的想法发

热点内容
武汉大学学生会辅导员寄语 发布:2021-03-16 21:44:16 浏览:612
七年级学生作文辅导学案 发布:2021-03-16 21:42:09 浏览:1
不屑弟高考成绩 发布:2021-03-16 21:40:59 浏览:754
大学毕业证会有成绩单 发布:2021-03-16 21:40:07 浏览:756
2017信阳学院辅导员招聘名单 发布:2021-03-16 21:40:02 浏览:800
查询重庆2018中考成绩查询 发布:2021-03-16 21:39:58 浏览:21
结业考试成绩怎么查询 发布:2021-03-16 21:28:40 浏览:679
14中医医师资格笔试考试成绩查分 发布:2021-03-16 21:28:39 浏览:655
名著赏析课程标准 发布:2021-03-16 21:27:57 浏览:881
北京大学商业领袖高端培训课程 发布:2021-03-16 21:27:41 浏览:919