eclipse做java小游戏(用eclipse编写Java小游戏怎样才能生成 Executable Jar File文件)

本文目录
- 用eclipse编写Java小游戏怎样才能生成 Executable Jar File文件
- eclipse 下做的 java android的小飞机游戏 求解释 简单说一下里面代码表示的都是什么
- 急需一个小游戏 1010的java代码 最好在eclipse上
- java急急急,谁可以告诉我eclipse中小游戏的入口代码怎么写
- 那个大神有完整的java,eclipse,2048游戏的源代码,全部拷贝粘贴就能用的,给一个,在线等,急!!!
用eclipse编写Java小游戏怎样才能生成 Executable Jar File文件
项目右键,单击export,选择java,选择jar file,点击next;
勾选要打包的java类后,点击next,点击next
在Main class中选择入口类,点击finish
祝你好运
eclipse 下做的 java android的小飞机游戏 求解释 简单说一下里面代码表示的都是什么
上面的class文件为游戏的主体代码,继承SurfaceView这个类并且实现SurfaceHolder的回调方法,简单一点说就是根据游戏需要画图并显示到屏幕。
public void handleMessage(Message m) {}应该是一个接受消息的方法
里面的判断都是根据你下面定义的静态常量的状态来匹配的,下面那个class PlaneGame类定义了一些静态常量。
class KeyGameEvent 类主要是控制触屏或者说按键的
急需一个小游戏 1010的java代码 最好在eclipse上
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
class mypanel extends Panel implements MouseListener
{
int chess;
boolean Is_Black_True;
mypanel()
{
Is_Black_True = true;
for(int i = 0;i 《 11;i++)
{
for(int j = 0;j 《 11;j++)
{
chess = 0;
}
}
addMouseListener(this);
setBackground(Color.BLUE);
setBounds(0, 0, 360, 360);
setVisible(true);
}
public void mousePressed(MouseEvent e)
{
int x = e.getX();
int y = e.getY();
if(x 《 25 || x 》 330 + 25 ||y 《 25 || y 》 330+25)
{
return;
}
if(chess != 0)
{
return;
}
if(Is_Black_True == true)
{
chess = 1;
Is_Black_True = false;
repaint();
Justisewiner();
return;
}
if(Is_Black_True == false)
{
chess = 2;
Is_Black_True = true;
repaint();
Justisewiner();
return;
}
}
void Drawline(Graphics g)
{
for(int i = 30;i 《= 330;i += 30)
{
for(int j = 30;j 《= 330; j+= 30)
{
g.setColor(Color.WHITE);
g.drawLine(i, j, i, 330);
}
}
for(int j = 30;j 《= 330;j += 30)
{
g.setColor(Color.WHITE);
g.drawLine(30, j, 330, j);
}
}
void Drawchess(Graphics g)
{
for(int i = 0;i 《 11;i++)
{
for(int j = 0;j 《 11;j++)
{
if(chess == 1)
{
g.setColor(Color.BLACK);
g.fillOval((i + 1) * 30 - 8, (j + 1) * 30 - 8, 16, 16);
}
if(chess == 2)
{
g.setColor(Color.WHITE);
g.fillOval((i + 1) * 30 - 8, (j + 1) * 30 - 8, 16, 16);
}
}
}
}
void Justisewiner()
{
int black_count = 0;
int white_count = 0;
int i = 0;
for(i = 0;i 《 11;i++)//横向判断
{
for(int j = 0;j 《 11;j++)
{
if(chess == 1)
{
black_count++;
if(black_count == 5)
{
JOptionPane.showMessageDialog(this, "黑棋胜利");
Clear_Chess();
return;
}
}
else
{
black_count = 0;
}
if(chess == 2)
{
white_count++;
if(white_count == 5)
{
JOptionPane.showMessageDialog(this, "白棋胜利");
Clear_Chess();
return;
}
}
else
{
white_count = 0;
}
}
}
for(i = 0;i 《 11;i++)//竖向判断
{
for(int j = 0;j 《 11;j++)
{
if(chess == 1)
{
black_count++;
if(black_count == 5)
{
JOptionPane.showMessageDialog(this, "黑棋胜利");
Clear_Chess();
return;
}
}
else
{
black_count = 0;
}
if(chess == 2)
{
white_count++;
if(white_count == 5)
{
JOptionPane.showMessageDialog(this, "白棋胜利");
Clear_Chess();
return;
}
}
else
{
white_count = 0;
}
}
}
for(i = 0;i 《 7;i++)//左向右斜判断
{
for(int j = 0;j 《 7;j++)
{
for(int k = 0;k 《 5;k++)
{
if(chess == 1)
{
black_count++;
if(black_count == 5)
{
JOptionPane.showMessageDialog(this, "黑棋胜利");
Clear_Chess();
return;
}
}
else
{
black_count = 0;
}
if(chess == 2)
{
white_count++;
if(white_count == 5)
{
JOptionPane.showMessageDialog(this, "白棋胜利");
Clear_Chess();
return;
}
}
else
{
white_count = 0;
}
}
}
}
for(i = 4;i 《 11;i++)//右向左斜判断
{
for(int j = 6;j 》= 0;j--)
{
for(int k = 0;k 《 5;k++)
{
if(chess == 1)
{
black_count++;
if(black_count == 5)
{
JOptionPane.showMessageDialog(this, "黑棋胜利");
Clear_Chess();
return;
}
}
else
{
black_count = 0;
}
if(chess == 2)
{
white_count++;
if(white_count == 5)
{
JOptionPane.showMessageDialog(this, "白棋胜利");
Clear_Chess();
return;
}
}
else
{
white_count = 0;
}
}
}
}
}
void Clear_Chess()
{
for(int i=0;i《11;i++)
{
for(int j=0;j《11;j++)
{
chess=0;
}
}
repaint();
}
public void paint(Graphics g)
{
Drawline(g);
Drawchess(g);
}
public void mouseExited(MouseEvent e){}
public void mouseEntered(MouseEvent e){}
public void mouseReleased(MouseEvent e){}
public void mouseClicked(MouseEvent e){}
}
class myframe extends Frame implements WindowListener
{
mypanel panel;
myframe()
{
setLayout(null);
panel = new mypanel();
add(panel);
panel.setBounds(0,23, 360, 360);
setTitle("单人版五子棋");
setBounds(200, 200, 360, 383);
setVisible(true);
addWindowListener(this);
}
public void windowClosing(WindowEvent e)
{
System.exit(0);
}
public void windowDeactivated(WindowEvent e){}
public void windowActivated(WindowEvent e){}
public void windowOpened(WindowEvent e){}
public void windowClosed(WindowEvent e){}
public void windowIconified(WindowEvent e){}
public void windowDeiconified(WindowEvent e){}
}
public class mywindow
{
public static void main(String argc )
{
myframe f = new myframe();
}
}
java急急急,谁可以告诉我eclipse中小游戏的入口代码怎么写
入口函数
public static void main (String agrs){
//中间填写代码,两个斜杠是注释。
}
那个大神有完整的java,eclipse,2048游戏的源代码,全部拷贝粘贴就能用的,给一个,在线等,急!!!
网上的java代码在eclipse里运行方法:
1.打开eclipse,点击项目的空白处,选择import;
2.选择Existing Project into Workspace,点击next,找到的java代码,导入到eclipse中;
3.导入成功之后,选择项目,鼠标右键,选择run as,选择一个运行方式,然后运行即可。

更多文章:
unknown hard error是什么意思(unknown hard error是什么意思)
2025年9月1日 17:15
getconsolewindow(C语言 怎么使控制台窗口大小固定不变)
2025年6月6日 16:00
建站大师排名表2021(国内二次元手游2021年流水数据揭晓,最大赢家是谁)
2026年1月2日 02:15
html怎么在表格里加表格(如何在html单元格中插入表格并铺满单元格)
2026年5月14日 03:45
编号非自动列表是什么意思(word中项目符号,编号,多级列表什么区别及各用在什么场合)
2026年8月17日 05:15
oracle10客户端安装(Oracle Database 10g在windows上安装错误怎么解决)
2026年8月25日 13:00
nip和pluck的区别?百万英镑中,有这么一句,just like an englishman ,you see ,plu
2026年9月14日 14:15













