package pers.zhaxi.shootgame.shoot01;
import java.util.Random;
/*
* 所有飞行物的超类
* 英雄机 Hero
* 小敌机 Airplan
* 大敌机 BigAirplan
* 超大敌机 SuperAirplan
* 所有相同的行为方法写到超类里,设置为普通方法,如有子类有自己的特征重写
* 所有不同的行为方法写到超类里,设置为抽象方法
*/
public class FlingObject {
//所有派生类飞行物共有的属性
protected int width ; //宽度
protected int height ; //高度
protected int x ; //位置 x坐标
protected int y ; //位置 y坐标
/*
*构造方法 父类构造方法
*供子类的小敌机 大敌机 超敌机使用
*因为他们的 x y 的设置相同 都要从上面随机向下运动
*/
public FlingObject(int width , int height ){
this.width = width ;
this.height = height ;
Random ran = new Random() ;
x = ran.nextInt(480-width) ;
y = -height ;
}
//供子类的天空 英雄机 使用
public FlingObject(int width , int height, int x ,int y ){
this.width = width ;
this.height = height ;
this.x = x ;
this.y = y ;
}
//如何运动的方法 供子类重写
public vo