java打枪源代码 JAVA源代码和源文件

谁有java游戏源码,给我发过来‘?

注意:源代码仅供个人作学习研究时的参考,不得在程序制作中直接抄录。

我们提供的服务有:网站制作、成都网站制作、微信公众号开发、网站优化、网站认证、密山ssl等。为近千家企事业单位解决了网站和推广的问题。提供周到的售前咨询和贴心的售后服务,是有科学管理、有技术的密山网站制作公司

源代码一共两个文件:Mine.java,MGame.java,另外还有一些图片。

在JBuilder下建立一个新的工程,将两个源文件复制到工程目录下的src\mine目录中,将所有图片复制到src\images目录中就可以了。

要点分析

数据结构

首先要说明一下用来存放地雷信息的数组grid。

grid是一个二维数组,第一位对应表格的行,第二位对应表格的列,比如grid[y][x]表示第y行第x列。每个字节的含义分三段:0-9表示已经挖开;10-19表示仍然埋藏;20-29表示做了标记。每段中:0-8表示周围的地雷数量;9表示是地雷。

newGame()函数

这是用于开始一个新游戏的。

由于每次地雷的埋放地是随机的,应次开始新游戏之前先要生成新的地雷信息。

第一步是初始化grid,将所有内容都置成10,因为一开始所有格子都是埋藏的。

for(i=0;iHeight; i++)

{

for(j=0; jWidth; j++)

grid[j] = 10;

}

第二步是随机产生地雷。当然了,已经产生过地雷的地方要避开。

for(i=0; iMINECOUNT; i++)

{

while(true)

{

x = Math.abs(rand.nextInt()) % Width;

y = Math.abs(rand.nextInt()) % Height;

if (grid[y][x] != 19)

{

grid[y][x] = 19;

break;

}

}

}

最后就是无雷处计算周围的雷数了。怎么计算?一个一个加就是了。

挖雷与做标记

在看一下按键响应函数keyPressed(int kcode),按1键是挖开动作。

前半部分表示如果当前焦点在一个埋藏格(值介于10到19之间),那么将其值减10,表示现在挖开。当然如果地下不是雷而且周围没有雷(值等于0)那么需要自动展开,这里调用了Expand(),(selx,sely)是当前焦点的表格坐标。

后半部分表示如果当前焦点在一个已经挖开的格子上(值小于10),那么就调用SafeExp()来自动挖开周围未挖的格子。

按3键是做标记动作。如果当前格是埋藏格,就做上标记(值加10);如果当前格已经做了标记,那么就去掉标记(值减10)。

自动展开

Expand()是一个嵌套函数,他的作用是将周围不含地雷的格子周围全部挖开,如果挖开的部分中也有周围不含地雷的格子,那么对那些格子也重复前面的操作,直到把相关的格子都挖开。挖的顺序是左上、上、右上、左、右、左下、下、右下,如果遇到一个周围不含地雷的格子(值为0)那么马上嵌套调用Expand()对那个格子进行处理。

SafeExp()是一个自动挖开周围未挖格子的函数。当然要实现这个功能是有条件的,就是周围做了标记的格子数量必须等于当前格所标的数字,也就是说玩家把周围所有的地雷都标记了(不管是否标错)。函数中第一个部分就是做以上条件的判断。

第二部分是把周围埋藏的格子挖开。但是由于玩家的错误可能标记了没有地雷的格子,而把有地雷的格子漏标了,所以先要检查一下没做标而有地雷的格子和做错标记的格子。如果没有这些错误,那么可以安全的翻开了,同时也要检查是否挖到周围不含雷的格子,有的话就要调用Expand()了。

SafeExp()的返回值表示是否引爆了地雷,就是标记错误,true表示是,false表示否。这主要用于判断这次游戏是否要结束。

类介绍

图像缓存 ExtendedImage

ExtendedImage是Siemens自己扩展的一个专用类,只在Siemens的Java中存在。

这个类主要是用做图像的缓存。大家不知道还有没有印象,以前在PC上编程的时候由于显示的速度比较慢,往往会开一片显示缓存,先把要现实的内容画到这片缓存中,全部画好后再一次性显示出来,ExtendedImage类就起到了这个作用。其实Java本身的Image类也可以实现类似的功能,但是显示速度好象不如人意,而且ExtendedImage更好用,所以我基本上都采用这个类。当然这对通用性是不利的。

ExtendImage的主要函数有:

void clear(byte color);

用给定的颜色填充整个图形区域。

void blitToScreen(int x, int y);

将缓存内容贴到显示屏上,(x,y)是屏幕左上角坐标。

Image getImage();

返回一个标准的Image类。可以通过ExtendImage.getImage().getGraphics()得到与其相关的Graphics对象,用来往ExtendImage上面画图。

求java小游戏源代码

表1. CheckerDrag.java

// CheckerDrag.javaimport java.awt.*;import java.awt.event.*;public class CheckerDrag extends java.applet.Applet{ // Dimension of checkerboard square. // 棋盘上每个小方格的尺寸 final static int SQUAREDIM = 40; // Dimension of checkerboard -- includes black outline. // 棋盘的尺寸 – 包括黑色的轮廓线 final static int BOARDDIM = 8 * SQUAREDIM + 2; // Dimension of checker -- 3/4 the dimension of a square. // 棋子的尺寸 – 方格尺寸的3/4 final static int CHECKERDIM = 3 * SQUAREDIM / 4; // Square colors are dark green or white. // 方格的颜色为深绿色或者白色 final static Color darkGreen = new Color (0, 128, 0); // Dragging flag -- set to true when user presses mouse button over checker // and cleared to false when user releases mouse button. // 拖动标记 --当用户在棋子上按下鼠标按键时设为true, // 释放鼠标按键时设为false boolean inDrag = false; // Left coordinate of checkerboard's upper-left corner. // 棋盘左上角的左方向坐标 int boardx; // Top coordinate of checkerboard's upper-left corner. //棋盘左上角的上方向坐标 int boardy; // Left coordinate of checker rectangle origin (upper-left corner). // 棋子矩形原点(左上角)的左方向坐标 int ox; // Top coordinate of checker rectangle origin (upper-left corner). // 棋子矩形原点(左上角)的上方向坐标 int oy; // Left displacement between mouse coordinates at time of press and checker // rectangle origin. // 在按键时的鼠标坐标与棋子矩形原点之间的左方向位移 int relx; // Top displacement between mouse coordinates at time of press and checker // rectangle origin. // 在按键时的鼠标坐标与棋子矩形原点之间的上方向位移 int rely; // Width of applet drawing area. // applet绘图区域的宽度 int width; // Height of applet drawing area. // applet绘图区域的高度 int height; // Image buffer. // 图像缓冲 Image imBuffer; // Graphics context associated with image buffer. // 图像缓冲相关联的图形背景 Graphics imG; public void init () { // Obtain the size of the applet's drawing area. // 获取applet绘图区域的尺寸 width = getSize ().width; height = getSize ().height; // Create image buffer. // 创建图像缓冲 imBuffer = createImage (width, height); // Retrieve graphics context associated with image buffer. // 取出图像缓冲相关联的图形背景 imG = imBuffer.getGraphics (); // Initialize checkerboard's origin, so that board is centered. // 初始化棋盘的原点,使棋盘在屏幕上居中 boardx = (width - BOARDDIM) / 2 + 1; boardy = (height - BOARDDIM) / 2 + 1; // Initialize checker's rectangle's starting origin so that checker is // centered in the square located in the top row and second column from // the left. // 初始化棋子矩形的起始原点,使得棋子在第一行左数第二列的方格里居中 ox = boardx + SQUAREDIM + (SQUAREDIM - CHECKERDIM) / 2 + 1; oy = boardy + (SQUAREDIM - CHECKERDIM) / 2 + 1; // Attach a mouse listener to the applet. That listener listens for // mouse-button press and mouse-button release events. // 向applet添加一个用来监听鼠标按键的按下和释放事件的鼠标监听器 addMouseListener (new MouseAdapter () { public void mousePressed (MouseEvent e) { // Obtain mouse coordinates at time of press. // 获取按键时的鼠标坐标 int x = e.getX (); int y = e.getY (); // If mouse is over draggable checker at time // of press (i.e., contains (x, y) returns // true), save distance between current mouse // coordinates and draggable checker origin // (which will always be positive) and set drag // flag to true (to indicate drag in progress). // 在按键时如果鼠标位于可拖动的棋子上方 // (也就是contains (x, y)返回true),则保存当前 // 鼠标坐标与棋子的原点之间的距离(始终为正值)并且 // 将拖动标志设为true(用来表明正处在拖动过程中) if (contains (x, y)) { relx = x - ox; rely = y - oy; inDrag = true; } } boolean contains (int x, int y) { // Calculate center of draggable checker. // 计算棋子的中心位置 int cox = ox + CHECKERDIM / 2; int coy = oy + CHECKERDIM / 2; // Return true if (x, y) locates with bounds // of draggable checker. CHECKERDIM / 2 is the // radius. // 如果(x, y)仍处于棋子范围内则返回true // CHECKERDIM / 2为半径 return (cox - x) * (cox - x) + (coy - y) * (coy - y) CHECKERDIM / 2 * CHECKERDIM / 2; } public void mouseReleased (MouseEvent e) { // When mouse is released, clear inDrag (to // indicate no drag in progress) if inDrag is // already set. // 当鼠标按键被释放时,如果inDrag已经为true, // 则将其置为false(用来表明不在拖动过程中) if (inDrag) inDrag = false; } }); // Attach a mouse motion listener to the applet. That listener listens // for mouse drag events. //向applet添加一个用来监听鼠标拖动事件的鼠标运动监听器 addMouseMotionListener (new MouseMotionAdapter () { public void mouseDragged (MouseEvent e) { if (inDrag) { // Calculate draggable checker's new // origin (the upper-left corner of // the checker rectangle). // 计算棋子新的原点(棋子矩形的左上角) int tmpox = e.getX () - relx; int tmpoy = e.getY () - rely; // If the checker is not being moved // (at least partly) off board, // assign the previously calculated // origin (tmpox, tmpoy) as the // permanent origin (ox, oy), and // redraw the display area (with the // draggable checker at the new // coordinates). // 如果棋子(至少是棋子的一部分)没有被 // 移出棋盘,则将之前计算的原点 // (tmpox, tmpoy)赋值给永久性的原点(ox, oy), // 并且刷新显示区域(此时的棋子已经位于新坐标上) if (tmpox boardx tmpoy boardy tmpox + CHECKERDIM boardx + BOARDDIM tmpoy + CHECKERDIM boardy + BOARDDIM) { ox = tmpox; oy = tmpoy; repaint (); } } } }); } public void paint (Graphics g) { // Paint the checkerboard over which the checker will be dragged. // 在棋子将要被拖动的位置上绘制棋盘 paintCheckerBoard (imG, boardx, boardy); // Paint the checker that will be dragged. // 绘制即将被拖动的棋子 paintChecker (imG, ox, oy); // Draw contents of image buffer. // 绘制图像缓冲的内容 g.drawImage (imBuffer, 0, 0, this); } void paintChecker (Graphics g, int x, int y) { // Set checker shadow color. // 设置棋子阴影的颜色 g.setColor (Color.black); // Paint checker shadow. // 绘制棋子的阴影 g.fillOval (x, y, CHECKERDIM, CHECKERDIM); // Set checker color. // 设置棋子颜色 g.setColor (Color.red); // Paint checker. // 绘制棋子 g.fillOval (x, y, CHECKERDIM - CHECKERDIM / 13, CHECKERDIM - CHECKERDIM / 13); } void paintCheckerBoard (Graphics g, int x, int y) { // Paint checkerboard outline. // 绘制棋盘轮廓线 g.setColor (Color.black); g.drawRect (x, y, 8 * SQUAREDIM + 1, 8 * SQUAREDIM + 1); // Paint checkerboard. // 绘制棋盘 for (int row = 0; row 8; row++) { g.setColor (((row 1) != 0) ? darkGreen : Color.white); for (int col = 0; col 8; col++) { g.fillRect (x + 1 + col * SQUAREDIM, y + 1 + row * SQUAREDIM, SQUAREDIM, SQUAREDIM); g.setColor ((g.getColor () == darkGreen) ? Color.white : darkGreen); } } } // The AWT invokes the update() method in response to the repaint() method // calls that are made as a checker is dragged. The default implementation // of this method, which is inherited from the Container class, clears the // applet's drawing area to the background color prior to calling paint(). // This clearing followed by drawing causes flicker. CheckerDrag overrides // update() to prevent the background from being cleared, which eliminates // the flicker. // AWT调用了update()方法来响应拖动棋子时所调用的repaint()方法。该方法从 // Container类继承的默认实现会在调用paint()之前,将applet的绘图区域清除 // 为背景色,这种绘制之后的清除就导致了闪烁。CheckerDrag重写了update()来 // 防止背景被清除,从而消除了闪烁。 public void update (Graphics g) { paint (g); }}

java新手,求完整的源代码

//都是从新手过来的,以下代码供参考

//1.

public class BankAccount {

private static String acctnum;

private static double money;

private static void showAcct() {

System.out.println("账号为: " + acctnum);

}

private static void showMoney() {

System.out.println("余额为: " + money);

}

public BankAccount(String acc, double m) {

this.acctnum = acc;

this.money = m;

}

public static void main(String[] args) {

BankAccount ba = new BankAccount("626600018888", 5000.00);

ba.showAcct();

ba.showMoney();

}

}

//2.

public class Triangle {

private static float a;

private static float b;

private static float c;

public Triangle(float a, float b, float c) {

this.a = a;

this.b = b;

this.c = c;

}

public static boolean judgeTriangle(float a, float b, float c) {

if ((a  Math.abs(b - c)  a  b + c)

 (b  Math.abs(a - c)  b  a + c)

 (c  Math.abs(a - b)  c  a + b))

return true;

else

return false;

}

public float getCircumference() {

return this.a + this.b + this.c;

}

}

//3.

public class TestTriangle {

public static void main(String[] args) {

Triangle t = new Triangle(5.3f,7.8f,9.3f);

if(t.judgeTriangle(5.3f,7.8f,9.3f)){

System.out.print("能够成三角形,周长为: ");

System.out.printf("%9.2f",t.getCircumference());}

else

System.out.println("不能构成三角形");

}

}

跪求,一个用java写的飞行射击类的游戏的源代码, 急啊啊啊。。。

有多急,敢多给点分吗,我刚好写了一个,类似以前的小霸王的那种

求一个JAVA游戏代码!!!急!!!

俄罗斯方块——java源代码提供

import java.awt.*;

import java.awt.event.*;

//俄罗斯方块类

public class ERS_Block extends Frame{

public static boolean isPlay=false;

public static int level=1,score=0;

public static TextField scoreField,levelField;

public static MyTimer timer;

GameCanvas gameScr;

public static void main(String[] argus){

ERS_Block ers = new ERS_Block("俄罗斯方块游戏 V1.0 Author:Vincent");

WindowListener win_listener = new WinListener();

ers.addWindowListener(win_listener);

}

//俄罗斯方块类的构造方法

ERS_Block(String title){

super(title);

setSize(600,480);

setLayout(new GridLayout(1,2));

gameScr = new GameCanvas();

gameScr.addKeyListener(gameScr);

timer = new MyTimer(gameScr);

timer.setDaemon(true);

timer.start();

timer.suspend();

add(gameScr);

Panel rightScr = new Panel();

rightScr.setLayout(new GridLayout(2,1,0,30));

rightScr.setSize(120,500);

add(rightScr);

//右边信息窗体的布局

MyPanel infoScr = new MyPanel();

infoScr.setLayout(new GridLayout(4,1,0,5));

infoScr.setSize(120,300);

rightScr.add(infoScr);

//定义标签和初始值

Label scorep = new Label("分数:",Label.LEFT);

Label levelp = new Label("级数:",Label.LEFT);

scoreField = new TextField(8);

levelField = new TextField(8);

scoreField.setEditable(false);

levelField.setEditable(false);

infoScr.add(scorep);

infoScr.add(scoreField);

infoScr.add(levelp);

infoScr.add(levelField);

scorep.setSize(new Dimension(20,60));

scoreField.setSize(new Dimension(20,60));

levelp.setSize(new Dimension(20,60));

levelField.setSize(new Dimension(20,60));

scoreField.setText("0");

levelField.setText("1");

//右边控制按钮窗体的布局

MyPanel controlScr = new MyPanel();

controlScr.setLayout(new GridLayout(5,1,0,5));

rightScr.add(controlScr);

//定义按钮play

Button play_b = new Button("开始游戏");

play_b.setSize(new Dimension(50,200));

play_b.addActionListener(new Command(Command.button_play,gameScr));

//定义按钮Level UP

Button level_up_b = new Button("提高级数");

level_up_b.setSize(new Dimension(50,200));

level_up_b.addActionListener(new Command(Command.button_levelup,gameScr));

//定义按钮Level Down

Button level_down_b =new Button("降低级数");

level_down_b.setSize(new Dimension(50,200));

level_down_b.addActionListener(new Command(Command.button_leveldown,gameScr));

//定义按钮Level Pause

Button pause_b =new Button("游戏暂停");

pause_b.setSize(new Dimension(50,200));

pause_b.addActionListener(new Command(Command.button_pause,gameScr));

//定义按钮Quit

Button quit_b = new Button("退出游戏");

quit_b.setSize(new Dimension(50,200));

quit_b.addActionListener(new Command(Command.button_quit,gameScr));

controlScr.add(play_b);

controlScr.add(level_up_b);

controlScr.add(level_down_b);

controlScr.add(pause_b);

controlScr.add(quit_b);

setVisible(true);

gameScr.requestFocus();

}

}

//重写MyPanel类,使Panel的四周留空间

class MyPanel extends Panel{

public Insets getInsets(){

return new Insets(30,50,30,50);

}

}

//游戏画布类

class GameCanvas extends Canvas implements KeyListener{

final int unitSize = 30; //小方块边长

int rowNum; //正方格的行数

int columnNum; //正方格的列数

int maxAllowRowNum; //允许有多少行未削

int blockInitRow; //新出现块的起始行坐标

int blockInitCol; //新出现块的起始列坐标

int [][] scrArr; //屏幕数组

Block b; //对方快的引用

//画布类的构造方法

GameCanvas(){

rowNum = 15;

columnNum = 10;

maxAllowRowNum = rowNum - 2;

b = new Block(this);

blockInitRow = rowNum - 1;

blockInitCol = columnNum/2 - 2;

scrArr = new int [32][32];

}

//初始化屏幕,并将屏幕数组清零的方法

void initScr(){

for(int i=0;irowNum;i++)

for (int j=0; jcolumnNum;j++)

scrArr[j]=0;

b.reset();

repaint();

}

//重新刷新画布方法

public void paint(Graphics g){

for(int i = 0; i rowNum; i++)

for(int j = 0; j columnNum; j++)

drawUnit(i,j,scrArr[j]);

}

//画方块的方法

public void drawUnit(int row,int col,int type){

scrArr[row][col] = type;

Graphics g = getGraphics();

tch(type){ //表示画方快的方法

case 0: g.setColor(Color.black);break; //以背景为颜色画

case 1: g.setColor(Color.blue);break; //画正在下落的方块

case 2: g.setColor(Color.magenta);break; //画已经落下的方法

}

g.fill3DRect(col*unitSize,getSize().height-(row+1)*unitSize,unitSize,unitSize,true);

g.dispose();

}

public Block getBlock(){

return b; //返回block实例的引用

}

//返回屏幕数组中(row,col)位置的属性值

public int getScrArrXY(int row,int col){

if (row 0 || row = rowNum || col 0 || col = columnNum)

return(-1);

else

return(scrArr[row][col]);

}

//返回新块的初始行坐标方法

public int getInitRow(){

return(blockInitRow); //返回新块的初始行坐标

}

//返回新块的初始列坐标方法

public int getInitCol(){

return(blockInitCol); //返回新块的初始列坐标

}

//满行删除方法

void deleteFullLine(){

int full_line_num = 0;

int k = 0;

for (int i=0;irowNum;i++){

boolean isfull = true;

L1:for(int j=0;jcolumnNum;j++)

if(scrArr[j] == 0){

k++;

isfull = false;

break L1;

}

if(isfull) full_line_num++;

if(k!=0 k-1!=i !isfull)

for(int j = 0; j columnNum; j++){

if (scrArr[j] == 0)

drawUnit(k-1,j,0);

else

drawUnit(k-1,j,2);

scrArr[k-1][j] = scrArr[j];

}

}

for(int i = k-1 ;i rowNum; i++){

for(int j = 0; j columnNum; j++){

drawUnit(i,j,0);

scrArr[j]=0;

}

}

ERS_Block.score += full_line_num;

ERS_Block.scoreField.setText(""+ERS_Block.score);

}

//判断游戏是否结束方法

boolean isGameEnd(){

for (int col = 0 ; col columnNum; col ++){

if(scrArr[maxAllowRowNum][col] !=0)

return true;

}

return false;

}

public void keyTyped(KeyEvent e){

}

public void keyReleased(KeyEvent e){

}

//处理键盘输入的方法

public void keyPressed(KeyEvent e){

if(!ERS_Block.isPlay)

return;

tch(e.getKeyCode()){

case KeyEvent.VK_DOWN:b.fallDown();break;

case KeyEvent.VK_LEFT:b.leftMove();break;

case KeyEvent.VK_RIGHT:b.rightMove();break;

case KeyEvent.VK_SPACE:b.leftTurn();break;

}

}

}

//处理控制类

class Command implements ActionListener{

static final int button_play = 1; //给按钮分配编号

static final int button_levelup = 2;

static final int button_leveldown = 3;

static final int button_quit = 4;

static final int button_pause = 5;

static boolean pause_resume = true;

int curButton; //当前按钮

GameCanvas scr;

//控制按钮类的构造方法

Command(int button,GameCanvas scr){

curButton = button;

this.scr=scr;

}

//按钮执行方法

public void actionPerformed (ActionEvent e){

tch(curButton){

case button_play:if(!ERS_Block.isPlay){

scr.initScr();

ERS_Block.isPlay = true;

ERS_Block.score = 0;

ERS_Block.scoreField.setText("0");

ERS_Block.timer.resume();

}

scr.requestFocus();

break;

case button_levelup:if(ERS_Block.level 10){

ERS_Block.level++;

ERS_Block.levelField.setText(""+ERS_Block.level);

ERS_Block.score = 0;

ERS_Block.scoreField.setText(""+ERS_Block.score);

}

scr.requestFocus();

break;

case button_leveldown:if(ERS_Block.level 1){

ERS_Block.level--;

ERS_Block.levelField.setText(""+ERS_Block.level);

ERS_Block.score = 0;

ERS_Block.scoreField.setText(""+ERS_Block.score);

}

scr.requestFocus();

break;

case button_pause:if(pause_resume){

ERS_Block.timer.suspend();

pause_resume = false;

}else{

ERS_Block.timer.resume();

pause_resume = true;

}

scr.requestFocus();

break;

case button_quit:System.exit(0);

}

}

}

//方块类

class Block {

static int[][] pattern = {

{0x0f00,0x4444,0x0f00,0x4444},//用十六进至表示,本行表示长条四种状态

{0x04e0,0x0464,0x00e4,0x04c4},

{0x4620,0x6c00,0x4620,0x6c00},

{0x2640,0xc600,0x2640,0xc600},

{0x6220,0x1700,0x2230,0x0740},

{0x6440,0x0e20,0x44c0,0x8e00},

{0x0660,0x0660,0x0660,0x0660}

};

int blockType; //块的模式号(0-6)

int turnState; //块的翻转状态(0-3)

int blockState; //快的下落状态

int row,col; //块在画布上的坐标

GameCanvas scr;

//块类的构造方法

Block(GameCanvas scr){

this.scr = scr;

blockType = (int)(Math.random() * 1000)%7;

turnState = (int)(Math.random() * 1000)%4;

blockState = 1;

row = scr.getInitRow();

col = scr.getInitCol();

}

//重新初始化块,并显示新块

public void reset(){

blockType = (int)(Math.random() * 1000)%7;

turnState = (int)(Math.random() * 1000)%4;

blockState = 1;

row = scr.getInitRow();

col = scr.getInitCol();

dispBlock(1);

}

//实现“块”翻转的方法

public void leftTurn(){

if(assertValid(blockType,(turnState + 1)%4,row,col)){

dispBlock(0);

turnState = (turnState + 1)%4;

dispBlock(1);

}

}

//实现“块”的左移的方法

public void leftMove(){

if(assertValid(blockType,turnState,row,col-1)){

dispBlock(0);

col--;

dispBlock(1);

}

}

//实现块的右移

public void rightMove(){

if(assertValid(blockType,turnState,row,col+1)){

dispBlock(0);

col++;

dispBlock(1);

}

}

//实现块落下的操作的方法

public boolean fallDown(){

if(blockState == 2)

return(false);

if(assertValid(blockType,turnState,row-1,col)){

dispBlock(0);

row--;

dispBlock(1);

return(true);

}else{

blockState = 2;

dispBlock(2);

return(false);

}

}

//判断是否正确的方法

boolean assertValid(int t,int s,int row,int col){

int k = 0x8000;

for(int i = 0; i 4; i++){

for(int j = 0; j 4; j++){

if((int)(pattern[t][s]k) != 0){

int temp = scr.getScrArrXY(row-i,col+j);

if (temp0||temp==2)

return false;

}

k = k 1;

}

}

return true;

}

//同步显示的方法

public synchronized void dispBlock(int s){

int k = 0x8000;

for (int i = 0; i 4; i++){

for(int j = 0; j 4; j++){

if(((int)pattern[blockType][turnState]k) != 0){

scr.drawUnit(row-i,col+j,s);

}

k=k1;

}

}

}

}

//定时线程

class MyTimer extends Thread{

GameCanvas scr;

public MyTimer(GameCanvas scr){

this.scr = scr;

}

public void run(){

while(true){

try{

sleep((10-ERS_Block.level + 1)*100);

}

catch(InterruptedException e){}

if(!scr.getBlock().fallDown()){

scr.deleteFullLine();

if(scr.isGameEnd()){

ERS_Block.isPlay = false;

suspend();

}else

scr.getBlock().reset();

}

}

}

class WinListener extends WindowAdapter{

public void windowClosing (WindowEvent l){

System.exit(0);

}

}

什么是java源代码 怎么查看

你说的java源代码是指编译成的class文件前的java文件。

当我们运行.java文件时,它会被系统编译成.class文件,例如Test.java编译之后就是Test.class,

源文件就是指Test.java文件,

一般部署项目时,有.class文件就可以发布运行了,但是如果想修改这个系统,.class是不能修改的,要有.java文件才能修改

也可以上网去下反编译软件,就是能把.class文件大部分还原成.java文件的工具,但不是100%还原,而且如果不是正版的,小心有毒啊,什么的。


网页题目:java打枪源代码 JAVA源代码和源文件
当前URL:http://myzitong.com/article/hhocoo.html