求一款java游戏开发

求一个简单的Java小游戏的代码_百度知道
该问题可能描述不清,建议你
求一个简单的Java小游戏的代码
我有更好的答案
消除方法控制 public void init(){ mainFrame=new JFrame(&rows & 5;twins++) { randoms=(int)(M southP),cols,rows,y0=0,x=0,y=0,fristMsg=0,5)),secondMsg=0.add(centerPanel,450); mainFrame,&quot.add(northPanel,&North&quot.grid[i][j]!=0) { save[n]=this.grid[i][j]; n++; } } } n=n-1; this.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= //这里一定要将按钮点击信息归为初始 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= pressInformation= } else { x0=x; y0=y; fristMsg=secondM firstButton=secondB x=placeX; y=placeY; secondMsg=grid[x][y]; secondButton= 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;
} else{ k=1; } //K=1说明通过了第一次验证 } if (k==1) { linePassOne(); } } if (y&j){ //如果第二个按钮的Y坐标小于空按钮的Y坐标说明第一按钮在第二按钮右边 for (i=y+1;i&=i++ ){ //判断第二按钮左侧直到第一按钮中间有没有按钮 if (grid[x][i]!=0){ k=0;
} 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;
} 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;
} 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&=j-- ) { if (grid[j][y]!=0) { k=0;
} else { k=1; } } if (k==1) { rowPassOne(); } } if (x&i) { for (j=x+1;j&=i;j++ ) { if (grid[j][y]!=0) { k=0;
} 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;
} 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;
} if(grid[i][n]==0 && n==y+1) { remove(); } } } } } } } public void linePassOne(){ if (y0&j){ //第一按钮同行空按钮在左边 for (i=y0-1;i&=i-- ){ //判断第一按钮同左侧空按钮之间有没按钮 if (grid[x0][i]!=0) { k=0;
} else { k=2; } //K=2说明通过了第二次验证 } } if (y0&j){ //第一按钮同行空按钮在与第二按钮之间 for (i=y0+1;i&=i++){ if (grid[x0][i]!=0) { k=0;
} else{ k=2; } } } } public void rowPassOne(){ if (x0&i) { for (j=x0-1;j&=j-- ) { if (grid[j][y0]!=0) { k=0;
} else { k=2; } } } if (x0&i) { for (j=x0+1;j&=j++ ) { if (grid[j][y0]!=0) { k=0;
} else { k=2; } } } } public void remove(){ firstButton.setVisible(false); secondButton.setVisible(false); fraction(); pressInformation= 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 = randomBuild(); mainFrame.setVisible(false); pressInformation= 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); / } } exitButton=new JButton(&Center&quot.add(diamondsButton[cols][rows]); for(int twins=1;twins&游戏按钮的位置坐标 int i,validateLV; //).addActionListener(this),n; thisContainer = mainFrame.getContentPane(),cols,rows.add(exitButton).// northPanel.random()*5+1),100.setVisible(true); } public void randomBuild() {
fractionLable.setText(String.valueOf(I for(int cols = 0;/分数标签 JButton firstB southP/游戏按钮数组 JButton exitButton,resetButton,newlyB /&#47.add(fractionLable); mainF=5;j++) { if( exitBalike&=2; rows=(int)(Math.random()*5+1); } this.grid[cols][rows]=退出,重列.*;储存游戏按钮位置 static boolean pressInformation= /&#47.setBounds(280;i++) { for(int j=0;j&lt,j;退出&quot.parseInt(fractionLable.getText())+100)).parseInt(fractionLable.getText()))); while(grid[cols][rows];i&=6;子面板 JButton diamondsButton[][] = new JButton[6][5];/=15;cols & 6; centerPanel.setLayout(new GridLayout(6,northP // resetButton=new JButton(&重列&); resetButton,secondB /&#47.valueOf(grid[cols+1][rows+1])); diamondsButton[cols][rows].addActionListener(this); centerPanel.addActionListener(this); thisContainer.add(southPJKJ连连看& thisContainer.setLayout(new BorderLayout()); centerPanel=new JPanel(); southPanel=new JPanel();// int grid[][]= new int[8][7]; for(int i=0;rows++ ){ diamondsButton[cols][rows]=new JButton(S判断是否有按钮被选中 int x0=0;South&); thisC } public void reload() { int save[] = new int[30]; int n=0; import java.awt.event.*; public class lianliankan implements ActionListener { JFrame mainFrame,&quot.valueOf(I newlyButton=new JButton(&再来一局&); newlyButton连连看的小源码package L } } } public void fraction(){ fractionLable.setText(String,重新开始按钮 JLabel fractionLable=new JLabel(&0&分别记录两次被选中的按钮 int grid[][] = new int[8][7].random()*6+1); northPanel=new JPanel(); thisCcols++){ for(int rows = 0!=0) { cols=(int)(Math,k;alike++) { cols=(int)(Math.random()*6+1); rows=(int)(Math.random()*25+1); for(int alike=1;).add(resetButton); southPanel.add(newlyButton),500.addActionListener(this);); //主面板 Container thisC JPanel centerPanel,southPimport javax.swing.*; import java
你要新建java工程 上网搜下java小游戏源码 自己好好看看
好吧,我用的是文本
采纳率:31%
现在还在玩 java游戏啊
1条折叠回答
为您推荐:
其他类似问题
您可能关注的内容
小游戏 java 代码的相关知识
换一换
回答问题,赢新手礼包
个人、企业类
违法有害信息,请在下方选择后提交
色情、暴力
我们会通过消息、邮箱等方式尽快将举报结果通知您。很久以前玩的一款java游戏,求名称_百度知道
很久以前玩的一款java游戏,求名称
我有更好的答案
俄罗斯方块、贪吃蛇超级玛丽、魂斗罗
超级玛丽?木有图片 木有真相 你是说一些java 游戏吗
java 格式的游戏多了,你不说明谁知道
为您推荐:
其他类似问题
java游戏的相关知识
换一换
回答问题,赢新手礼包
个人、企业类
违法有害信息,请在下方选择后提交
色情、暴力
我们会通过消息、邮箱等方式尽快将举报结果通知您。0被浏览236分享邀请回答暂时还没有回答,开始写第一个回答}

我要回帖

更多关于 求一款好玩的单机游戏 的文章

更多推荐

版权声明:文章内容来源于网络,版权归原作者所有,如有侵权请点击这里与我们联系,我们将及时删除。

点击添加站长微信