资源简介

达内私有课程java面向对象课程,飞机大战项目,达内飞机大战素材包,包括所有代码,达内私有课程

资源截图

代码片段和文件信息

package cn.tedu.shoot;
import java.awt.image.BufferedImage;
/** 小敌机:是飞行物,也是分 */
public class Airplane extends Flyingobject implements Enemy {
/*
 * A:静态变量,静态块赋值-----------最好的
 *   --第一次new对象(方法区分配images一份,静态块赋一次值)
 *   --以后new对象----什么也不做了
 * B:实例变量,构造中赋值
 *   --第一次new对象(堆中分配images,构造中赋一次值)
 *   --第二次new对象(堆中分配images,构造中赋一次值)
 *   --第三次new对象(堆中分配images,构造中赋一次值)
 * C:静态变量,构造中赋值
 *   --第一次new对象(方法区分配images一份,构造中赋一次值)
 *   --第二次new对象(构造中赋一次值)
 *   --第三次new对象(构造中赋一次值)
 */

private static BufferedImage[] images; //图片
static{
images = new BufferedImage[5];
for(int i=0;i images[i] = loadImage(“airplane“+i+“.png“);
}
}

private int speed; //移动速度
/** 构造方法 */
public Airplane(){
super(4936);
speed = 2;
}

/** 重写step()移动 */
public void step(){
y+=speed; //y+(向下)
}

int index = 1; //死了时的起始下标
/** 重写getImage()获取图片 */
public BufferedImage getImage(){ //每10毫秒走一次
if(isLife()){ //若为活着的,则返回images[0]
return images[0];
}else if(isDead()){ //若为死了的
BufferedImage img = images[index++]; //images[1]到images[4]
if(index==images.length){ //若到最后一张图片了
state = REMOVE; //将对象状态修改为删除状态
}
return img;
}
return null; //REMOVE状态时,返回null
/*
 *                   index=1
 * 10M img=images[1] index=2                  返回images[1]
 * 20M img=images[2] index=3                  返回images[2]
 * 30M img=images[3] index=4                  返回images[3]
 * 40M img=images[4] index=5(REMOVE) 返回images[4]
 * 50M 
 */
}

/** 重写getScore()得分 */
public int getScore(){
return 1; //打掉小敌机,玩家得1分
}

}


















 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----

     文件        301  2018-10-13 14:47  MyShoot\.classpath

     文件        383  2018-10-13 14:47  MyShoot\.project

     文件        598  2018-10-13 14:47  MyShoot\.settings\org.eclipse.jdt.core.prefs

     文件       1467  2018-10-25 09:39  MyShoot\bin\cn\tedu\shoot\Airplane.class

     文件       3575  2017-08-20 19:05  MyShoot\bin\cn\tedu\shoot\airplane0.png

     文件       2619  2017-08-20 19:05  MyShoot\bin\cn\tedu\shoot\airplane1.png

     文件       2954  2017-08-20 19:05  MyShoot\bin\cn\tedu\shoot\airplane2.png

     文件       4047  2017-08-20 19:05  MyShoot\bin\cn\tedu\shoot\airplane3.png

     文件       1439  2017-08-20 19:05  MyShoot\bin\cn\tedu\shoot\airplane4.png

     文件        217  2018-10-25 09:39  MyShoot\bin\cn\tedu\shoot\Award.class

     文件      26709  2017-08-20 19:05  MyShoot\bin\cn\tedu\shoot\background.png

     文件       1742  2018-10-25 09:39  MyShoot\bin\cn\tedu\shoot\Bee.class

     文件       6405  2017-08-20 19:05  MyShoot\bin\cn\tedu\shoot\bee0.png

     文件       6416  2017-08-20 19:05  MyShoot\bin\cn\tedu\shoot\bee1.png

     文件       6428  2017-08-20 19:05  MyShoot\bin\cn\tedu\shoot\bee2.png

     文件       6404  2017-08-20 19:05  MyShoot\bin\cn\tedu\shoot\bee3.png

     文件       6367  2017-08-20 19:05  MyShoot\bin\cn\tedu\shoot\bee4.png

     文件       1476  2018-10-25 09:39  MyShoot\bin\cn\tedu\shoot\BigAirplane.class

     文件       6762  2017-08-20 19:05  MyShoot\bin\cn\tedu\shoot\bigplane0.png

     文件       7932  2017-08-20 19:05  MyShoot\bin\cn\tedu\shoot\bigplane1.png

     文件       8682  2017-08-20 19:05  MyShoot\bin\cn\tedu\shoot\bigplane2.png

     文件       9831  2017-08-20 19:05  MyShoot\bin\cn\tedu\shoot\bigplane3.png

     文件       2672  2017-08-20 19:05  MyShoot\bin\cn\tedu\shoot\bigplane4.png

     文件       1032  2018-10-25 09:39  MyShoot\bin\cn\tedu\shoot\Bullet.class

     文件        408  2017-08-20 19:05  MyShoot\bin\cn\tedu\shoot\bullet.png

     文件        130  2018-10-25 09:39  MyShoot\bin\cn\tedu\shoot\Enemy.class

     文件       2559  2018-10-25 09:39  MyShoot\bin\cn\tedu\shoot\Flyingobject.class

     文件      20220  2017-08-20 19:05  MyShoot\bin\cn\tedu\shoot\gameover.png

     文件       1951  2018-10-25 15:37  MyShoot\bin\cn\tedu\shoot\Hero.class

     文件      12280  2017-08-20 19:05  MyShoot\bin\cn\tedu\shoot\hero0.png

............此处省略52个文件信息

评论

共有 条评论