java游戏源代码
‘壹’ 求"大家来找茬"游戏的java源代码
其实不难,原理如下:
建立数据结构,此结构应该有的属性为:
1。图A(原图),
2。图B(有差别的图),
3。不同点的坐标区域
原理:窗口中显示两个图,在每个图上添加鼠标点击事件,在鼠标点击后在判断坐标是否在坐标区域内
用NetBeans半小时应该就能做好,程序不难,麻烦的是图片的制作或者寻找,然后规定坐标区域
回答完毕,如果你想要程序我又时间了可以考虑给你做一个
‘贰’ 求java小游戏源代码
[最佳答案] 连连看java源代码 import javax.swing.*; import java.awt.*; import java.awt.event.*; pu... int x0=0,y0=0,x=0,y=0,fristMsg=0,secondMsg=0,validateLV; //游戏按钮的位...
‘叁’ 急需基于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[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();
}
}
‘肆’ 游戏软件怎么查看源代码
源代码是看不成的,因为游戏软件打包好做成app的话,是没法看源码的,虽然存在一些特殊情况下,我们可以推测出exe程序是用什么程序写的。但是多数情况下,我们是无法只根据一个exe程序就判断出来的。
根据exe程序我们是无法直接得到程序的源码的。虽然也有一些用于逆向工程的办法,但那不可能把已经是exe的程序反回到它原始的源码情况。而且这些工具都很难用。你可以用“反编译”搜到很多工具,但是说实话,即便是这方面的专家,要看懂反编译以后的程序也不是一件轻松的事情。
‘伍’ 求JAVA编写打字游戏源代码!
package chen;
import java.awt.*;
import java.awt.event.*;
import java.awt.image.BufferedImage;
import java.util.Vector;
import javax.swing.JFrame;
public class keyTest extends Window implements KeyListener, Runnable {
int width, height;
BufferedImage buf;
Graphics gc;
boolean play = true;
Vector<oneChar> keys = new Vector<oneChar>();
int ok = 0, fail = 0, error = 0, sum = 0;
Font small = new Font("宋体", 0, 30);
Font big = new Font("宋体", 0, 50);
long time = System.currentTimeMillis();
keyTest(Frame f) {
super(f);
Dimension s = getToolkit().getScreenSize();
width = (int) s.getWidth();
height = (int) s.getHeight();
this.setBounds(0, 0, width, height);
this.buf = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
gc = buf.getGraphics();
this.setVisible(true);
this.setAlwaysOnTop(true);
this.buf = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
gc = buf.getGraphics();
new Thread(this).start();
}
public static void main(String s[]) {
JFrame help = new JFrame("打字练习");
help.setVisible(true);
help.setDefaultCloseOperation(3);
help.addKeyListener(new keyTest(help));
}
public void keyTyped(KeyEvent e) {
}
public synchronized void keyPressed(KeyEvent e) {
if (e.getKeyCode() == 27) {
play = false;
this.dispose();
System.exit(0);
}
char s = e.getKeyChar();
if (s >= 'a' && s <= 'z' || (s >= 'A' && s <= 'Z')) {
String l = "" + s;
for (int i = 0; i < keys.size(); i++) {
if (l.equals(((oneChar) keys.elementAt(i)).s)) {
keys.removeElementAt(i);
ok++;
return;
}
}
error++;
}
}
public void keyReleased(KeyEvent e) {
}
@Override
public void update(Graphics g) {
gc.setColor(Color.BLACK);
gc.fillRect(0, 0, width, height);
gc.setColor(Color.red);
int l = (ok + error) > 0 ? (ok * 100 / (ok + error)) : 100;
gc.setFont(small);
gc.drawString("成功:" + ok + " 错误:" + error + " 失败:" + fail + " 正确率:" + l + "% 时间:" + (System.currentTimeMillis() - time) / 1000, 10, height - 30);
gc.setFont(big);
oneChar o;
for (int i = 0; i < keys.size(); i++) {
o = keys.elementAt(i);
gc.setColor(o.c);
gc.drawString(o.s, o.x, o.y += 6);
if (o.y > height - 10) {
fail++;
keys.removeElementAt(i);
}
}
g.drawImage(buf, 0, 0, null);
}
public void run() {
while (play) {
try {
sum++;
if (sum % 5 == 0) {
newchar();
}
Thread.sleep(80);
repaint();
} catch (InterruptedException ex) {
ex.printStackTrace();
}
}
}
private void newchar() {
keys.add(oneChar.getinstance(width));
}
}
package chen;
import java.awt.Color;
public class oneChar {
static java.util.Random r = new java.util.Random();
public static oneChar getinstance(int maxX) {
oneChar a = new oneChar();
int b = r.nextInt(26);
a.s = "" + (char) (b + (r.nextInt(4) > 1 ? 'a' : 'A'));
a.x = r.nextInt(maxX - 30);
a.c = new Color(r.nextInt(256), r.nextInt(256), r.nextInt(256));
return a;
}
int x, y;
Color c;
String s;
}
‘陆’ 小游戏十滴水的java源代码,急
第一个Java文件: import java.util.Scanner; public class GameA_B {
public static void main(String[] args) {
Scanner reader=new Scanner(System.in);
int area;
System.out.println("Game Start…………Please enter the area:(1-9)" + '\n'+"1,2,3 means easy"+'\n'+"4,5,6 means middle"+'\n'+ "7,8,9 means hard"+'\n'+"Please choose:");
area=reader.nextInt();
switch((area1)/3) {
case 0:System.out.println("You choose easy! ");break;
case 1:System.out.println("You choose middle! ");break; case 2:System.out.println("You choose hard! ");break; } System.out.println("Good Luck!"); GameProcess game1=new GameProcess(area); game1.process(); } } 第二个Java文件: import java.util.Random; import java.util.Scanner; public class GameProcess { int area,i,arrcount,right,midright,t; int base[]=new int[arrcount],userNum[]=new int[area],sysNum[]=new int[area]; Random random=new Random(); Scanner reader=new Scanner(System.in); GameProcess(int a) { area=a; arrcount=10; right=0; midright=0; t=0; base=new int[arrcount]; userNum=new int[area]; sysNum=new int[area]; for(int i=0;i<arrcount;i++) { base[i]=i; //System.out.println(base[i]); } } void process() { rand(); while(right!=area) { scanf(); compare(); print(); check(); } } void rand() { for(i=0;i<area;i++) { t=random.nextInt(arrcount); //System.out.println(t); sysNum[i]=base[t]; System.out.println(base[t]); delarr(t); } } void delarr(int t) { for(int j=t;j<arrcount-1;j++) base[j]=base[j+1]; arrcount--; } void scanf() { System.out.println("The system number has created!"+"\n"+"Please enter "+area+" Numbers"); for(int i=0;i<area;i++){ userNum[i]=reader.nextShort(); } } void check() { if(right==area) System.out.println("You win…………!"); } boolean check(int i) { return true; } void compare() { int i=0,j=0; right=midright=0; for(i=0;i<area;i++) { for(j=0;j<area;j++) { if(userNum[i]==sysNum[j]) { if(i==j) right++; else midright++; } } } } void print() { System.out.println(" A "+right+" B "+midright); } }
自己慢慢分吧!!!!!!!
‘柒’ 求一个简单又有趣的JAVA小游戏代码
具体如下:
连连看的小源码
package Lianliankan;
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;//消除方法控制
代码(code)是程序员用开发工具所支持的语言写出来的源文件,是一组由字符、符号或信号码元以离散形式表示信息的明确的规则体系。
对于字符和Unicode数据的位模式的定义,此模式代表特定字母、数字或符号(例如 0x20 代表一个空格,而 0x74 代表字符“t”)。一些数据类型每个字符使用一个字节;每个字节可以具有 256 个不同的位模式中的一个模式。
在计算机中,字符由不同的位模式(ON 或 OFF)表示。每个字节有 8 位,这 8 位可以有 256 种不同的 ON 和 OFF 组合模式。对于使用 1 个字节存储每个字符的程序,通过给每个位模式指派字符可表示最多 256 个不同的字符。2 个字节有 16 位,这 16 位可以有 65,536 种唯一的 ON 和 OFF 组合模式。使用 2 个字节表示每个字符的程序可表示最多 65,536 个字符。
单字节代码页是字符定义,这些字符映射到每个字节可能有的 256 种位模式中的每一种。代码页定义大小写字符、数字、符号以及 !、@、#、% 等特殊字符的位模式。每种欧洲语言(如德语和西班牙语)都有各自的单字节代码页。
虽然用于表示 A 到 Z 拉丁字母表字符的位模式在所有的代码页中都相同,但用于表示重音字符(如"é"和"á")的位模式在不同的代码页中却不同。如果在运行不同代码页的计算机间交换数据,必须将所有字符数据由发送计算机的代码页转换为接收计算机的代码页。如果源数据中的扩展字符在接收计算机的代码页中未定义,那么数据将丢失。
如果某个数据库为来自许多不同国家的客户端提供服务,则很难为该数据库选择这样一种代码页,使其包括所有客户端计算机所需的全部扩展字符。而且,在代码页间不停地转换需要花费大量的处理时间。