急需基于eclipse的JAVA小游戏源代码!!! 10

最好是整个工程,包括图片啊什么素材,导入就可运行的,或者每个.class文件都分开,我粘贴在elipse里就能运行的~~~~~~谢谢万分感谢~~~~~要交的作业啊,好心的... 最好是整个工程,包括图片啊什么素材,导入就可运行的,或者每个.class文件都分开,我粘贴在elipse里就能运行的~~~~~~谢谢万分感谢~~~~~要交的作业啊,好心的高手来帮帮忙吧!!!(只有10 分了 抱歉。。)
我的邮箱 malan_gjx@sohu.com
展开
 我来答
bill76554792
推荐于2017-11-23 · TA获得超过954个赞
知道小有建树答主
回答量:723
采纳率:50%
帮助的人:593万
展开全部
单人版五子棋,不用导入,直接新建一个mywindow类就行,然后把一下代码粘贴就Ok了。或者,直接用dos就可以了。。
---------------------
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;

class mypanel extends Panel implements MouseListener
{
int chess[][] = new int[11][11];
boolean Is_Black_True;
mypanel()
{
Is_Black_True = true;
for(int i = 0;i < 11;i++)
{
for(int j = 0;j < 11;j++)
{
chess[i][j] = 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[x/30-1][y/30-1] != 0)
{
return;
}
if(Is_Black_True == true)
{
chess[x/30-1][y/30-1] = 1;
Is_Black_True = false;
repaint();
Justisewiner();
return;
}
if(Is_Black_True == false)
{
chess[x/30-1][y/30-1] = 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[i][j] == 1)
{
g.setColor(Color.BLACK);
g.fillOval((i + 1) * 30 - 8, (j + 1) * 30 - 8, 16, 16);
}
if(chess[i][j] == 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[i][j] == 1)
{
black_count++;
if(black_count == 5)
{
JOptionPane.showMessageDialog(this, "黑棋胜利");
Clear_Chess();
return;
}
}
else
{
black_count = 0;
}
if(chess[i][j] == 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[j][i] == 1)
{
black_count++;
if(black_count == 5)
{
JOptionPane.showMessageDialog(this, "黑棋胜利");
Clear_Chess();
return;
}
}
else
{
black_count = 0;
}
if(chess[j][i] == 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[i + k][j + k] == 1)
{
black_count++;
if(black_count == 5)
{
JOptionPane.showMessageDialog(this, "黑棋胜利");
Clear_Chess();
return;
}
}
else
{
black_count = 0;
}
if(chess[i + k][j + k] == 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[i - k][j + k] == 1)
{
black_count++;
if(black_count == 5)
{
JOptionPane.showMessageDialog(this, "黑棋胜利");
Clear_Chess();
return;
}
}
else
{
black_count = 0;
}
if(chess[i - k][j + k] == 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[i][j]=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();
}
}
科技潮流先知
2019-11-10 · TA获得超过3643个赞
知道大有可为答主
回答量:3050
采纳率:30%
帮助的人:231万
展开全部
单人版五子棋,不用导入,直接新建一个mywindow类就行,然后把一下代码粘贴就Ok了。或者,直接用dos就可以了。。
---------------------
import
java.awt.*;
import
java.awt.event.*;
import
javax.swing.*;
class
mypanel
extends
Panel
implements
MouseListener
{
int
chess[][]
=
new
int[11][11];
boolean
Is_Black_True;
mypanel()
{
Is_Black_True
=
true;
for(int
i
=
0;i
<
11;i++)
{
for(int
j
=
0;j
<
11;j++)
{
chess[i][j]
=
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[x/30-1][y/30-1]
!=
0)
{
return;
}
if(Is_Black_True
==
true)
{
chess[x/30-1][y/30-1]
=
1;
Is_Black_True
=
false;
repaint();
Justisewiner();
return;
}
if(Is_Black_True
==
false)
{
chess[x/30-1][y/30-1]
=
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[i][j]
==
1)
{
g.setColor(Color.BLACK);
g.fillOval((i
+
1)
*
30
-
8,
(j
+
1)
*
30
-
8,
16,
16);
}
if(chess[i][j]
==
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[i][j]
==
1)
{
black_count++;
if(black_count
==
5)
{
JOptionPane.showMessageDialog(this,
"黑棋胜利");
Clear_Chess();
return;
}
}
else
{
black_count
=
0;
}
if(chess[i][j]
==
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[j][i]
==
1)
{
black_count++;
if(black_count
==
5)
{
JOptionPane.showMessageDialog(this,
"黑棋胜利");
Clear_Chess();
return;
}
}
else
{
black_count
=
0;
}
if(chess[j][i]
==
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[i
+
k][j
+
k]
==
1)
{
black_count++;
if(black_count
==
5)
{
JOptionPane.showMessageDialog(this,
"黑棋胜利");
Clear_Chess();
return;
}
}
else
{
black_count
=
0;
}
if(chess[i
+
k][j
+
k]
==
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[i
-
k][j
+
k]
==
1)
{
black_count++;
if(black_count
==
5)
{
JOptionPane.showMessageDialog(this,
"黑棋胜利");
Clear_Chess();
return;
}
}
else
{
black_count
=
0;
}
if(chess[i
-
k][j
+
k]
==
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[i][j]=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();
}
}
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
百笑侃天下
2010-07-08 · 超过11用户采纳过TA的回答
知道答主
回答量:111
采纳率:0%
帮助的人:21.3万
展开全部
我有写过一些小游戏,如果坦克,贪吃蛇,不知道你能不能用,
576648859@qq.com
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
maxueruby
2010-07-08 · TA获得超过141个赞
知道答主
回答量:47
采纳率:0%
帮助的人:11.4万
展开全部
maxueruby001@163.COM

楼主 我有的 你给我发个邮件 主题说明下 我会给你发的。我最近也在用eclipse跑j2me的小游戏

晚上我才回寝室,在寝室的电脑上。 现在在实验室。
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
收起 2条折叠回答
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式