1.急需基于eclipse的小项JAVA小游戏源代码!!目开码!发源签到积分礼品网站源码
急需基于eclipse的小项JAVA小游戏源代码!!目开码重庆源码时代环境!发源视酷源码专业
单人版五子棋,小项不用导入,目开码直接新建一个mywindow类就行,发源然后把一下代码粘贴就Ok了。小项或者,目开码直接用dos就可以了。发源。小项源码和防伪码
---------------------
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
class mypanel extends Panel implements MouseListener
{
int chess[][] = new int[][];
boolean Is_Black_True;
mypanel()
{
Is_Black_True = true;
for(int i = 0;i < ;i++)
{
for(int j = 0;j < ;j++)
{
chess[i][j] = 0;
}
}
addMouseListener(this);
setBackground(Color.BLUE);
setBounds(0,目开码 0, , );
setVisible(true);
}
public void mousePressed(MouseEvent e)
{
int x = e.getX();
int y = e.getY();
if(x < || x > + ||y < || y > +)
{
return;
}
if(chess[x/-1][y/-1] != 0)
{
return;
}
if(Is_Black_True == true)
{
chess[x/-1][y/-1] = 1;
Is_Black_True = false;
repaint();
Justisewiner();
return;
}
if(Is_Black_True == false)
{
chess[x/-1][y/-1] = 2;
Is_Black_True = true;
repaint();
Justisewiner();
return;
}
}
void Drawline(Graphics g)
{
for(int i = ;i <= ;i += )
{
for(int j = ;j <= ; j+= )
{
g.setColor(Color.WHITE);
g.drawLine(i, j, i, );
}
}
for(int j = ;j <= ;j += )
{
g.setColor(Color.WHITE);
g.drawLine(, j, , j);
}
}
void Drawchess(Graphics g)
{
for(int i = 0;i < ;i++)
{
for(int j = 0;j < ;j++)
{
if(chess[i][j] == 1)
{
g.setColor(Color.BLACK);
g.fillOval((i + 1) * - 8, (j + 1) * - 8, , );
}
if(chess[i][j] == 2)
{
g.setColor(Color.WHITE);
g.fillOval((i + 1) * - 8, (j + 1) * - 8, , );
}
}
}
}
void Justisewiner()
{
int black_count = 0;
int white_count = 0;
int i = 0;
for(i = 0;i < ;i++)//横向判断
{
for(int j = 0;j < ;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 < ;i++)//竖向判断
{
for(int j = 0;j < ;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 < ;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<;i++)
{
for(int j=0;j<;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,, , );
setTitle("单人版五子棋");
setBounds(, , , );
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();
}
}
知情人士稱特朗普正考慮對FBI領導層進行改組
白鹭冰雪源码编译
辅助个人网站源码_辅助个人网站源码怎么弄
苏州商城平台源码_苏州商城平台源码是什么
引力波源码_引力波软件
麒麟源码 整站资源_麒麟软件源