Unify enemy delete routine for when they leave the screen
This commit is contained in:
parent
148c9ca491
commit
9b109fe722
|
@ -38,13 +38,16 @@ public abstract class Enemy extends ShootingEntity {
|
|||
*/
|
||||
public void update() {
|
||||
super.update();
|
||||
|
||||
// enemy has fully left the screen ..to the left!
|
||||
if(this.getX() + this.getWidth() < 0){
|
||||
this.remove();
|
||||
return;
|
||||
}
|
||||
|
||||
if(willShoot == true){
|
||||
this.shoot();
|
||||
}
|
||||
// ToDo: ???
|
||||
if(this.getX() < 0-this.getWidth()) {
|
||||
this.remove();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -47,9 +47,6 @@ public class EnemyThree extends Enemy{
|
|||
public void update() {
|
||||
super.update();
|
||||
this.setPosition(this.getX()-1, this.getY());
|
||||
if(this.getX() < 0-getWidth()){
|
||||
this.remove();
|
||||
}
|
||||
Player player = GameScreen.getPlayer();
|
||||
if(this.getY() < player.getY()){
|
||||
this.newY += ySpeed;
|
||||
|
|
|
@ -24,9 +24,6 @@ public class EnemyTwo extends Enemy{
|
|||
public void update() {
|
||||
super.update();
|
||||
this.setPosition(this.getX()-1, this.getY());
|
||||
if(this.getX() < 0-getWidth()){
|
||||
this.remove();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -90,7 +90,8 @@ public final class Level {
|
|||
//If the rule matches the current time, spawn the configured Entity in the configured amount:
|
||||
for(int i=0; i<spawnrule[2]; i++) {
|
||||
//TODO: More beautiful positions!
|
||||
this.spawnEntityByAvailableName(Entity.availableNames.values()[spawnrule[1]], GameConfig.windowWidth - 25, Random.nextInt(GameConfig.windowHeight -50)+50);
|
||||
//ToDo: X is GameConfig.windowWidth - somePixels, should be the whole width (for enemies coming into the screen from the right).
|
||||
this.spawnEntityByAvailableName(Entity.availableNames.values()[spawnrule[1]], GameConfig.windowWidth - 50, Random.nextInt(GameConfig.windowHeight -50)+50);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue