package FlyHero;
import java.util.Random;
public class Airplane extends FlyingObject implements Enemy{
private int speed = 2;
public Airplane(){
this.image = ShootGame.airplane;
width = image.getWidth();
height = image.getHeight();
y = -height;
Random rand = new Random();
x = rand.nextInt(ShootGame.WIDTH - width);
}
@Override
public void step(){
y += speed;
}
@Override
public int getScore(){
return 3;
}
}
//-----------------------------------------------------------------------------------------------------------------------
package FlyHero;
public interface Award {
int DOUBLE_FIRE = 0;
int LIFE = 1;
int getType();
}
//-----------------------------------------------------------------------------------------------------------------------
package FlyHero;
import java.util.Random;
public class Bee extends FlyingObject implements Award{
private int xSpeed = 1;
private int ySpeed = 2;
private int awardType;
public Bee(){
this.image = ShootGame.bee;
width = image.getWidth();
height = image.getHeight();
y = -height;
Random rand = new Random();
x = rand.nextInt(ShootGame.WIDTH - width);
awardType = rand.nextInt(2);
}
@Override
public void step(){
x += xSpeed;
y += ySpeed;
if(x>ShootGame.WIDTH-width){
xSpeed = -1;
}
if(x<0){
xSpeed = 1;
}
}
public int getType(){
return awardType;
}
}
//-----------------------------------------------------------------------------------------------------------------------
package FlyHero;
import java.util.Random;
public class Boss extends FlyingObject implements Enemy{
private int awardType;
private int xSpeed = 1;
private int ySpeed = 2;
private int life;
static int i;
@Override
public void step(){
x += xSpeed;
y = 10;
if(x>ShootGame.WIDTH-width){
xSpeed = -1;
}
if(x<0){
xSpeed = 1;
}
i = x;
}
public Boss(){
life = 100;
this.image = ShootGame.boss0;
width = image.getWidth();
height = image.getHeight();
y = this.y+100;
Random rand = new Random();
// x = this.x;
awardType = rand.nextInt(2);
}
public BossBullet[] shoot(){
int xStep = this.width/4;
int yStep = 20;
BossBullet[] bossbullets = new BossBullet[1];
bossbullets[0] = new BossBullet(this.i+2*xStep-16,this.y-yStep);
return bossbullets;
}
@Override
public int getScore(){
return 50;
}
public int getType(){
return awardType;
}
public boolean die(){
return false;
}
public void subtractLife(){
life--;
}
public int getLife(){
return life;
}
public boolean hit(FlyingObject other){
int x1 = other.x - this.width/2;
int x2 = other.x + this.width/2 + other.width;
int y1 = other.y - this.height/2;
int y2 = other.y + this.height/2 + other.height;
int herox = this.x + this.width/2;
int heroy = this.y + this.height/2;
return herox>x1 && heroxy1 && heroy
}
}
//-----------------------------------------------------------------------------------------------------------------------
package FlyHero;
public class BossBullet extends FlyingObject{
pr