最美情侣中文字幕电影,在线麻豆精品传媒,在线网站高清黄,久久黄色视频

歡迎光臨散文網(wǎng) 會(huì)員登陸 & 注冊(cè)

Java原創(chuàng)創(chuàng)意,自制素材,加音效坦克大戰(zhàn),原創(chuàng)up主游戲,較完整簡(jiǎn)單版1【詩書畫唱】

2020-09-25 08:44 作者:詩書畫唱  | 我要投稿


背景.png
封茗囧茵0.gif
封茗囧茵1.gif
封茗囧茵4.gif
封茗囧茵3.gif
封茗囧茵2.gif
時(shí)間靜止之術(shù).png
閃電.png
沒電了.png(白色的字“沒電了”)
開始的圖片.png
雙笙4.gif
雙笙3.gif
雙笙2.gif
雙笙1.gif
雙笙0.gif
lex1.png
lex0.png
Warma4.gif
Warma3.gif
Warma2.gif
Warma1.gif
Warma0.gif

package 坦克大戰(zhàn)完整版;

import java.awt.Color;

import java.awt.Graphics;

import java.awt.event.KeyEvent;

import java.awt.event.KeyListener;


import javax.swing.*;




import java.util.*;

//這個(gè)來做繪制內(nèi)容,發(fā)射子彈一類的操作

//讓這個(gè)類實(shí)現(xiàn)鍵盤點(diǎn)擊的接口

public class caoZuo extends JPanel implements KeyListener,Runnable{

//在構(gòu)造法方法里實(shí)例化我方坦克

// arraylist:存儲(chǔ)任意類型,內(nèi)容長度任意,有下標(biāo)

Vector<diRenTanKe> diRenTanKeVector

=new Vector<diRenTanKe>();

myTanKe myTanKe=null;

public caoZuo(){

myTanKe=new myTanKe(150,440,0);

for(int i=0;i<5;i++){

diRenTanKe d=new diRenTanKe(100*i, 0, 2);

diRenTanKeVector.add(d);

Thread Thread=new Thread(d);

Thread.start();

}

}

//繪制的方法

public void paint(Graphics g){

g.setColor(Color.black);

g.fillRect(0,0,600,600);

g.setColor(Color.green);

//上:

huiZhiTanKeFangFa(g,myTanKe.TanKeFuLeiX,

myTanKe.TanKeFuLeiY,0,

myTanKe.TanKeFuLeiFangXiang);


//點(diǎn)擊J鍵,myTanK寫坦克的方法,判斷其方式,繪制子彈

//遍歷子彈的集合,子彈有幾發(fā)就繪制幾發(fā)

for(int i=0;i<myTanKe.v.size();i++){

ziDanClass z=myTanKe.v.get(i);

//得到每一發(fā)子彈

//說明這個(gè)子彈是存在的,

// 并且子彈的生命為真的時(shí)候才繪制子彈

if(z!=null&&z.shengMing){

g.fillRect(z.x,z.y,10,10);

}

//如果子彈的生命為false,也就是子彈達(dá)到了頁面的邊界

//就移除該子彈

if(!z.shengMing){

myTanKe.v.remove(z);

}

}

//遍歷剛才存入的5個(gè)敵方坦克

for(int i=0;i<diRenTanKeVector.size();i++){

diRenTanKe diRenTanKe

=diRenTanKeVector.get(i);

if(diRenTanKe!=null&&diRenTanKe.shengMing){

huiZhiTanKeFangFa(g,diRenTanKe.TanKeFuLeiX,

diRenTanKe.TanKeFuLeiY,1,diRenTanKe.TanKeFuLeiFangXiang);

}

if(diRenTanKe!=null&&diRenTanKe.shengMing){

//得到坦克的子彈

Vector<ziDanClass> v_zidan=diRenTanKe.v;

//遍歷每個(gè)坦克的地方子彈

for(ziDanClass j:v_zidan){

//如果每個(gè)子彈確實(shí)存在并且每個(gè)子彈的生命為真就可以

//繪制子彈了

if(j!=null&&j.shengMing){

g.fillRect(j.x, j.y, 10,10);

}

}

}

}

}

//封裝坦克的方法

// 1.畫筆? ?2.x? 3.y? 4.坦克的類型? 5.坦克的方向

public void huiZhiTanKeFangFa(Graphics g,int x,int y,int leixing,int fangxiang){

//在這個(gè)方法里既可以繪制我方坦克,也可以繪制

//敵方TanK,TanK的類型就是判斷是繪制什么顏色的坦克

switch(leixing){

case 0:

//畫我方坦克

g.setColor(Color.green);break;

case 1:

g.setColor(Color.yellow);break;

}

switch(fangxiang){

case 0://向上

g.fillRect(x, y, 10,30);

g.fillRect(x+10, y-10, 10,30);

g.fillRect(x+20, y, 10,30);

break;

case 1://向右

g.fillRect(x, y, 30,10);

g.fillRect(x+10, y+10, 30,10);

g.fillRect(x, y+20, 30,10);

break;

case 2://向下

g.fillRect(x, y, 10,30);

g.fillRect(x+10, y+10, 10,30);

g.fillRect(x+20, y, 10,30);

break;

case 3://向左

g.fillRect(x, y, 30,10);

g.fillRect(x-10, y+10, 30,10);

g.fillRect(x, y+20, 30,10);

break;

}



}

@Override

public void keyTyped(KeyEvent e) {

// TODO Auto-generated method stub


}

@Override

//鍵盤按下的事件

public void keyPressed(KeyEvent e) {

//點(diǎn)擊W鍵

if(e.getKeyCode()==KeyEvent.VK_W){

myTanKe.yidong(0);

}

if(e.getKeyCode()==KeyEvent.VK_S){

myTanKe.yidong(2);

}

if(e.getKeyCode()==KeyEvent.VK_A){

myTanKe.yidong(3);

}

if(e.getKeyCode()==KeyEvent.VK_D){

myTanKe.yidong(1);

}

//點(diǎn)擊j的時(shí)候發(fā)射子彈111

if(e.getKeyCode()==KeyEvent.VK_J){

if(myTanKe.v.size()<=2){//v的大小已經(jīng)為6? j

new Thread(new shengYin("blast.wav")).start() ;

myTanKe.kaipao(myTanKe.TanKeFuLeiFangXiang);


}

}

this.repaint();

}

private? void jztk(TanKeFuLei t,ziDanClass z){

// ——————

// 下面的是用instanceof來判斷

// z.x是所屬的哪個(gè)子類(diRenTanKe

// 或myTanKe),用

// z.x>=t.x&&z.x<=t.x+35&&z.y>=t.y&&z.y<=t.y+35

// 來判斷我的坦克的子彈是否擊中了敵人的坦克。

// 如果打中了,就用z.shengMing=false;

// t.shengMing=false;

// 分別讓我的坦克的子彈和敵人的坦克隱藏,就是不顯示,

// 就是會(huì)消失。


if(t instanceof diRenTanKe){



if(z.x>=t.TanKeFuLeiX&&z.x<=t.TanKeFuLeiX+35&&z.y>=t.TanKeFuLeiY&&z.y<=t.TanKeFuLeiY+35){

// new Thread(new shengyin("hit.wav")).start() ;

z.shengMing=false;

t.shengMing=false;

}

}

//if(t instanceof myTanKe){

//

//

// if(z.x>=t.x&&z.x<=t.x+35&&z.y>=t.y&&z.y<=t.y+35){

//// new Thread(new shengyin("hit.wav")).start() ;

// z.shengMing=false;

// t.shengMing=false;

// }

// }

}

@Override

public void keyReleased(KeyEvent e) {

// TODO Auto-generated method stub


}

@Override

public void run() {

while(true){

//new Thread(new shengyin("start.wav")).start() ;

try {

Thread.sleep(10);


} catch (InterruptedException e) {

// TODO Auto-generated catch block

e.printStackTrace();

}

//如果我方坦克是存在的才可以發(fā)射子彈

if(myTanKe.shengMing&&myTanKe!=null){

//遍歷所有的我方子彈:

for(int i=0;i<myTanKe.v.size();i++){

//如果遍歷的子彈的生命值為true也就是這個(gè)子彈存在

//就遍歷所有的地方坦克

if(myTanKe.v.get(i).shengMing){

//遍歷所有的地方坦克

for(int j=0;j<diRenTanKeVector.size();j++){

//得到所有的敵方坦克

diRenTanKe d=diRenTanKeVector.get(j);

//執(zhí)行擊中坦克的方法

jztk(d,myTanKe.v.get(i));


//執(zhí)行擊中坦克的方法

// jztk(myRenTanKe,m.v.get(i));


}

jztk(myTanKe,myTanKe.z);

}

}



}

this.repaint();

}

}

}



package 坦克大戰(zhàn)完整版;


import java.util.Random;

import java.util.Vector;


public class diRenTanKe extends TanKeFuLei implements Runnable{

//地方坦克子彈的集合

Vector<ziDanClass> v=new Vector<ziDanClass>();

//敵方坦克類也是繼承坦克父類

public diRenTanKe(int x, int y, int fangxiang) {

super(x, y, fangxiang);

this.suDu=5;

}

@Override

public void run() {

while(true){

// try {

// Thread.sleep(200);

// } catch (InterruptedException e) {

// e.printStackTrace();

// }

yidong();

//在這個(gè)位置添加子彈

//當(dāng)前坦克是存在的

if(this.shengMing){

ziDanClass z=null;

switch(TanKeFuLeiFangXiang){

case 0:

z=new ziDanClass(TanKeFuLeiX+10,TanKeFuLeiY-10,this.TanKeFuLeiFangXiang);break;

case 1:

z=new ziDanClass(TanKeFuLeiX+40,TanKeFuLeiY+10,this.TanKeFuLeiFangXiang);break;

case 2:

z=new ziDanClass(TanKeFuLeiX+10,TanKeFuLeiY+40,this.TanKeFuLeiFangXiang);break;

case 3:

z=new ziDanClass(TanKeFuLeiX-20,TanKeFuLeiY+10,this.TanKeFuLeiFangXiang);break;

}

//將子彈添加到子彈集合里

v.add(z);

Thread t=new Thread(z);

t.start();

}

}

}


private void yidong() {

Random r=new Random();

int shuzi=r.nextInt(4);

switch(shuzi){

case 0:

for(int i=0;i<30;i++){

if(this.TanKeFuLeiY>=10){

try {

Thread.sleep(40);

} catch (InterruptedException e) {

// TODO Auto-generated catch block

e.printStackTrace();

}

this.TanKeFuLeiY-=this.suDu;

}

this.TanKeFuLeiFangXiang=0;

}

break;

case 1:

for(int i=0;i<30;i++){

if(this.TanKeFuLeiX<=40){


try {

Thread.sleep(40);

} catch (InterruptedException e) {

// TODO Auto-generated catch block

e.printStackTrace();

}

this.TanKeFuLeiX+=this.suDu;

}

this.TanKeFuLeiFangXiang=1;

}

break;

case 2:

for(int i=0;i<30;i++){

if(this.TanKeFuLeiY<=500){


try {

Thread.sleep(40);

} catch (InterruptedException e) {

// TODO Auto-generated catch block

e.printStackTrace();

}

this.TanKeFuLeiY+=this.suDu;

}

this.TanKeFuLeiFangXiang=2;

}

break;

case 3:

for(int i=0;i<30;i++){

if(this.TanKeFuLeiX>=10){


try {

Thread.sleep(40);

} catch (InterruptedException e) {

// TODO Auto-generated catch block

e.printStackTrace();

}

this.TanKeFuLeiX-=this.suDu;

}

this.TanKeFuLeiFangXiang=3;

}

break;


}

}


}


package 坦克大戰(zhàn)完整版;

import java.awt.Color;

import javax.swing.*;

public class mains extends JFrame{

public static void main(String[] args) {

// 主函數(shù)調(diào)用mains類,同時(shí)會(huì)調(diào)用出其中包含的構(gòu)造方法:

new mains();

new Thread(new shengYin("start.wav")).start();

}


public? mains(){

?// 用來顯示頁面,設(shè)置頁面的部分:

this.setLayout(null);

this.setSize(600,600);

this.setLocationRelativeTo(null);

// ————


caoZuo caoZuo=new caoZuo();

// 因?yàn)閏aoZuo中有畫筆工具類Graphics,

// 類Graphics中有paint方法中自己寫的內(nèi)容。

// 所以設(shè)置caoZuo類就是設(shè)置caoZuo類中

// 畫圖中的頁面會(huì)顯示“g.setColor(Color.black);

// g.fillRect(0,0,600,600);”

// 黑色矩形等的大小,一般來說是設(shè)置

// caoZuo.setBounds(0,0,600,600)和

// 黑色矩形背景的大小相等的

caoZuo.setBounds(0,0,600,600);

//要想caoZuo中顯示的界面上的所有內(nèi)容都有鍵盤事件的話就要

//要把實(shí)例化好了的類caoZuo,添加到

//this.addKeyListener中的“()”中。


this.addKeyListener(caoZuo);

// ————


// 下面是開啟線程的部分(當(dāng)開啟線程時(shí),

// 就會(huì)調(diào)用線程中的run方法中所設(shè)置的內(nèi)容)

// 在mains類等處中的構(gòu)造方法中寫開啟線程的

// 部分時(shí),就是先要實(shí)例化繼承線程類B的類A,

// 之后要實(shí)例化把類A添加到“()”中的線程類B。

// 之后用start方法開啟線程。

Thread Thread=new Thread(caoZuo);

Thread.start();

this.add(caoZuo);

// ————

// 用來顯示頁面,設(shè)置頁面的部分:

this.setDefaultCloseOperation

(JFrame.EXIT_ON_CLOSE);

this.setVisible(true);

// ————

}

}


package 坦克大戰(zhàn)完整版;

import java.io.*;

import java.text.Format;


import javax.sound.sampled.*;

public class shengYin implements Runnable{

private String wenjianming;

public shengYin(String w){

this.wenjianming=w;

}

@Override

public void run() {

File File=new File(wenjianming);

AudioInputStream ais=null;

try {

ais=AudioSystem.getAudioInputStream(File);

AudioFormat af=ais.getFormat();

SourceDataLine sdl=null;

DataLine.Info dl=new DataLine.Info(SourceDataLine.class,af);

sdl=(SourceDataLine)AudioSystem.getLine(dl);

sdl.open(af);

sdl.start();

int len=0;

byte[] b=new byte[1024];

while(len!=-1){

len=ais.read(b,0,b.length);

if(len>=0){

sdl.write(b,0,len);

}

}

sdl.drain();

sdl.close();

} catch (Exception e) {

e.printStackTrace();

}



}


}

package 坦克大戰(zhàn)完整版;

//

//TanK英 [ta?k]美 [t??k]n.坦克;


//x,y

public class TanKeFuLei {

//這個(gè)TanKeFuLei為父類,敵人坦克和我的坦克

// 都是子類,繼承TanKeFuLei這個(gè)父類的。

//x軸,y軸,方向,速度,生命

int TanKeFuLeiX,TanKeFuLeiY,TanKeFuLeiFangXiang;

int suDu=15;//坦克默認(rèn)移動(dòng)的速度為15px

boolean shengMing=true;//每個(gè)坦克默認(rèn)都是存在的

public TanKeFuLei(int x,int y,int fangXiang){

// 很多變量是同名(可以所屬不同類的變量命名不同,

// 這時(shí)就可不用this,只要把傳的值和當(dāng)前的值用“=”賦值就可以,

// 但變量名會(huì)變多),

// 但所屬的類不同,這時(shí)要用this來區(qū)分(不區(qū)分,就可能報(bào)錯(cuò))。

//每次用swich或構(gòu)造方法等都是要用this(表示“當(dāng)前類的”)來區(qū)分

// 同名的。


this.TanKeFuLeiX=x;

this.TanKeFuLeiY=y;

this.TanKeFuLeiFangXiang=fangXiang;


}

}

package 坦克大戰(zhàn)完整版;

///111111

public class ziDanClass implements Runnable{

//x(子彈的x軸上方向的位移),

// y(子彈的y軸上方向的位移),

// fangXiang(子彈的方向),suDu(子彈移動(dòng)的速度)

// ,shengMing(子彈的生命):

int x,y,fangXiang;

int suDu=15;

boolean shengMing=true;

//默認(rèn)子彈是存在的,所以先讓子彈的shengMing為true

// ————

// 下面是子彈類中聲明的能夠傳值的構(gòu)造方法,可以通過

// “包名.方法名(對(duì)應(yīng)能夠傳值的構(gòu)造方法聲明的數(shù)據(jù)類型和個(gè)數(shù),

// 順序的

// 具體的值)”:

public ziDanClass(int x, int y, int fangxiang) {

this.x = x;

this.y = y;

this.fangXiang = fangxiang;

}

// ————

// 下面是在線程中的run方法中寫的

// 當(dāng)調(diào)用構(gòu)造方法時(shí),傳的對(duì)應(yīng)的fangxiang值(這里是設(shè)置為可

// 0,1,2,3)

// ,會(huì)執(zhí)行對(duì)應(yīng)的switch(this.fangXiang),進(jìn)而會(huì)執(zhí)行對(duì)應(yīng)的

// 有對(duì)應(yīng)的fangXiang

//case下面的內(nèi)容等

//

// (當(dāng)調(diào)用構(gòu)造方法時(shí),也會(huì)執(zhí)行run方法中的內(nèi)容)。


@Override

public void run() {

while(true){

try {

Thread.sleep(50);

switch(this.fangXiang){

case 0:

this.y-=this.suDu;break;

case 1:

this.x+=this.suDu;break;

case 2:

this.y+=this.suDu;break;

case 3:

this.x-=this.suDu;break;

}

} catch (InterruptedException e) {

// TODO Auto-generated catch block

e.printStackTrace();

}

// ————

//下面是判斷子彈是否達(dá)到邊界,如果子彈到達(dá)頁面的邊界(600)

//將子彈的生命設(shè)置為false,也就是讓子彈不再繪制。但這里把

// 600設(shè)置為500,讓其消失等的效果等更明顯等?

if(this.x<=0||this.y<=0||this.x>=500||this.y>=500){

shengMing=false;

}

}

}


}


————————————————————

原創(chuàng)up飛人游戲:

package duiXiang;


import img.img;


import java.awt.Graphics;

import java.awt.image.BufferedImage;


import mains.mains;


public class 背景 extends duiXiangFuLeiFangFa {


private static BufferedImage images;


// 靜態(tài)代碼塊

static {

images = img.loadImage("背景.png");

}


private int speed;// 速度

public int y1;// 第二張圖片的坐標(biāo)


public 背景() {

super(mains.quanJvWidth,

mains.quanJvHeight, 0, 0);

speed = 1;

y1 = -mains.quanJvHeight;

}

/*這里的圖片的高要比窗口的高大一些,圖片向上移動(dòng)時(shí)會(huì)出問題 */

public void yiDongFangFa() {

y += speed;

y1 += speed;

if (y >= mains.quanJvHeight) {

y = -mains.quanJvHeight;

}

if (y1 >= mains.quanJvHeight) {

y1 = -mains.quanJvHeight;

}

}


@Override

public BufferedImage getImageFangFa() {

return images;

}


/*重寫父類中的方法 */

@Override

public void paintObjectDuiXiangFangFa(Graphics g) {

g.drawImage(getImageFangFa(), x, y, null);

g.drawImage(getImageFangFa(), x, y1, null);

}


}

package duiXiang;

import img.img;


import java.awt.image.BufferedImage;


public class 封茗囧茵 extends duiXiangFuLeiFangFa?

implements diRen{


// 圖片

private static BufferedImage[] images;

//靜態(tài)代碼塊

static {

images = new BufferedImage[5];

for (int i = 0; i < images.length; i++) {

images[i] = img.loadImage("封茗囧茵" + i + ".gif");

}

}

private int speed;//速度



public 封茗囧茵(){

super(49, 36);

this.speed = 5;

}



public void yiDongFangFa(){

this.y += speed;

}


//得到圖片

int index = 1;

@Override

public BufferedImage getImageFangFa() {//10M

if (panDuanLife()) {

return images[0];

}else if(panDuanDead()){//圖片的切換

BufferedImage img = images[index++];

if (index == images.length) {

lifeOrDeadOrRemove = remove;

}

return img;

}

/*images[index++];

*? ?index = 1;

*? ?10M? images[1] index = 2? ?返回images[1]

*? ?20M? images[2] index = 3? ?返回images[2]

*? ?30M? images[3] index = 4? ?返回images[3]

* 40M? images[4] index = 5? ?返回images[4]

*?

*/

return null;

}


@Override

public int getScoreFangFa() {

return 1;

}

}


package duiXiang;

// 下面為得分接口:

public interface diRen {

/*用接口調(diào)用得分方法:*/

public int getScoreFangFa();

}

package duiXiang;


import java.awt.Graphics;

import java.awt.image.BufferedImage;

import java.util.Random;


import mains.mains;


public abstract class duiXiangFuLeiFangFa {


// 成員變量

protected int width;// 寬

protected int height;// 高

protected int x;// x坐標(biāo)

protected int y;// y坐標(biāo)

// 設(shè)計(jì)三種狀態(tài)

public static final int life = 0;// 存活

public static final int dead = 1;// over

public static final int remove = 2;// 刪除

public int lifeOrDeadOrRemove = life;// 當(dāng)前狀態(tài)為存活


public duiXiangFuLeiFangFa(int width, int height) {

this.width = width;

this.height = height;

Random rand = new Random();


this.x = rand.nextInt(mains.quanJvWidth?

- this.width);

this.y = -this.height;

}


/** 下面畫出對(duì)象,背景等的構(gòu)造方法,構(gòu)造方法和

* 把它包住的類的名稱是相同的 */

public duiXiangFuLeiFangFa(int width, int height,

int x, int y) {

this.width = width;

this.height = height;

this.x = x;

this.y = y;

}


// yiDongFangFa: 移動(dòng)方法?

public void yiDongFangFa() {

}


// 下面是調(diào)用圖片的抽象方法:

public abstract BufferedImage getImageFangFa();


/** paintObjectDuiXiangFangFa:

* 下面是用來繪制圖片到頁面的方法:

*?

*? */

public void paintObjectDuiXiangFangFa(Graphics g) {

g.drawImage(this.getImageFangFa(), this.x, this.y

,null);

}


/** 判斷當(dāng)前狀態(tài)是不是存活的 */

// lifeOrDeadOrRemove:生或死或移除

public boolean panDuanLife() {

return lifeOrDeadOrRemove == life;

}


/** 判斷當(dāng)前狀態(tài)是不是over的 */

public boolean panDuanDead() {

return lifeOrDeadOrRemove == dead;

}


/** 判斷當(dāng)前狀態(tài)是不是刪除的 */

public boolean panDuanRemove() {

return lifeOrDeadOrRemove == remove;

}


/** 檢測(cè)越界的方法 */

public boolean outOfBounds() {

return this.y >= mains.quanJvHeight;

}


public boolean hit(duiXiangFuLeiFangFa other) {

int x1 = this.x - other.width;

int y1 = this.y - other.height;

int x2 = this.x + this.width;

int y2 = this.y + this.height;

int x = other.x;

int y = other.y;

return x >= x1 && x <= x2 && y >= y1 && y <= y2;

}



public void goDead() {

lifeOrDeadOrRemove = dead;// 將對(duì)象狀態(tài)修改為DAED


}


public int getScoreFangFa() {

// TODO Auto-generated method stub

return 0;

}


}


package duiXiang;


public interface jiangLi {


int getAwardType();


}

package duiXiang;

import java.io.*;

import java.text.Format;


import javax.sound.sampled.*;

public class shengyin implements Runnable{

private String wenjianming;

public shengyin(String w){

this.wenjianming=w;

}

@Override

public void run() {

File f=new File(wenjianming);

AudioInputStream ais=null;

try {

ais=AudioSystem.getAudioInputStream(f);

AudioFormat af=ais.getFormat();

SourceDataLine sdl=null;

DataLine.Info dl=new DataLine.Info(SourceDataLine.class,af);

sdl=(SourceDataLine)AudioSystem.getLine(dl);

sdl.open(af);

sdl.start();

int len=0;

byte[] b=new byte[1024];

while(len!=-1){

len=ais.read(b,0,b.length);

if(len>=0){

sdl.write(b,0,len);

}

}

sdl.drain();

sdl.close();

} catch (Exception e) {

e.printStackTrace();

}



}


}


package duiXiang;


import img.img;


import java.awt.image.BufferedImage;

import java.util.Random;


import mains.mains;



public class Warma extends duiXiangFuLeiFangFa implements jiangLi{


private static BufferedImage[] imageArray;

// 靜態(tài)代碼塊

static {


// 這里調(diào)用的5張圖片只是透明度變得越來越小,

// 當(dāng)被“擊落”時(shí),會(huì)一起4張圖片調(diào)用,會(huì)“消失得”更自然

imageArray = new BufferedImage[5];

for (int i = 0; i < imageArray.length; i++) {


imageArray[i] = img.loadImage("Warma" + i + ".gif");

}




// images = new BufferedImage[1];

//

//

// images[0] = img.loadImage("Warma0.gif");

//




}


private int xSpeed;// x坐標(biāo)的速度

private int ySpeed;// y坐標(biāo)的速度

private int awardType;// 獲取獎(jiǎng)勵(lì)的類型


public Warma() {

super(29, 39);

xSpeed = 1;

ySpeed = 2;

Random rand = new Random();

awardType = rand.nextInt(2);// 0 1

}


public void yiDongFangFa() {

x += xSpeed;

y += ySpeed;

if (x < 0 || x >= mains.quanJvHeight - this.width) {

xSpeed *= -1;

}

}


// 得到圖片

int index = 1;

@Override

public BufferedImage getImageFangFa() {// 10M

if (panDuanLife()) {

return imageArray[0];

} else if (panDuanDead()) {// 圖片的切換

BufferedImage img = imageArray[index++];

if (index == imageArray.length) {

lifeOrDeadOrRemove = remove;

}

return img;

}

return null;

}


@Override

public int getAwardType() {

return awardType;

}


}





Java原創(chuàng)創(chuàng)意,自制素材,加音效坦克大戰(zhàn),原創(chuàng)up主游戲,較完整簡(jiǎn)單版1【詩書畫唱】的評(píng)論 (共 條)

分享到微博請(qǐng)遵守國家法律
临江市| 南开区| 策勒县| 巴南区| 晋城| 依安县| 五大连池市| 吴川市| 兴义市| 盐边县| 溆浦县| 安阳县| 廊坊市| 银川市| 三亚市| 象山县| 祁连县| 金堂县| 张家口市| 白城市| 曲周县| 黔江区| 兖州市| 印江| 河南省| 黎城县| 新丰县| 台南市| 饶平县| 体育| 兴化市| 辰溪县| 太原市| 齐齐哈尔市| 霍州市| 广德县| 仙居县| 玉环县| 湖北省| 沅陵县| 原阳县|