大战熟女丰满人妻av-荡女精品导航-岛国aaaa级午夜福利片-岛国av动作片在线观看-岛国av无码免费无禁网站-岛国大片激情做爰视频

專注Java教育14年 全國咨詢/投訴熱線:400-8080-105
動力節點LOGO圖
始于2009,口口相傳的Java黃埔軍校
首頁 hot資訊 Java游戲代碼之連連看

Java游戲代碼之連連看

更新時間:2021-05-18 10:38:11 來源:動力節點 瀏覽847次

連連看java源代碼

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

以上就是動力節點小編介紹的"Java游戲代碼之連連看",希望對大家有幫助,如有疑問,請在線咨詢,有專業老師隨時為您服務。

提交申請后,顧問老師會電話與您溝通安排學習

免費課程推薦 >>
技術文檔推薦 >>
主站蜘蛛池模板: 久久www免费人成高清 | 精品一区二区在线观看 | 久久精品免视看国产明星 | 午夜在线精品不卡国产 | 国产精品视频久久 | 日韩一区二区三区免费 | 欧美日本在线视频 | 日日狠狠久久8888av | 亚洲一区二区三区精品国产 | 毛茸茸的浓密在线视频 | 91成人午夜性a一级毛片 | 呦系列视频一区二区三区 | 深夜在线免费观看 | 国产a免费 | 日本一级毛片无遮挡 | 尹人香蕉久久99天天 | 五月情视频在线观看 | 美女个护士一级毛片亚洲 | 亚洲欧美日本在线观看 | 天天躁日日躁狠狠躁黑人躁 | 久久影视一区 | 四虎最新紧急更新地址 | 777777农村一级毛片 | 欧美成人免费看片一区 | 一级韩国aa毛片免费观看 | 操操操人人 | 一区欧美 | 欧洲在线免费视频 | 真人视频一级毛片 | 免费香蕉一区二区在线观看 | 国产舐足视频在线观看 | 国产精品午夜高清在线观看 | 中文字幕在线影院 | 极品美女aⅴ高清在线观看 极品美女一级毛片 | 日日干夜夜爱 | 一级特黄aaa大片免色 | 免费看欧美一级特黄a大片一 | 天天操天天碰 | 国产区精品福利在线观看精品 | 久久亚洲国产精品五月天婷 | 99视频国产在线 |