Move levelClock++ to the end, adjust interval checks.
This commit is contained in:
parent
52f038d4c4
commit
2ed07b430a
|
@ -109,8 +109,7 @@ public abstract class LivingEntity extends CollidableEntity implements Hittable
|
|||
* The default way the LivingEntity explodes. Override this method for a
|
||||
* different explosion behaviour.
|
||||
*/
|
||||
public void explode() {
|
||||
}
|
||||
public void explode() {}
|
||||
|
||||
/**
|
||||
* The default way the LivingEntity dies. Override this method for a
|
||||
|
|
|
@ -40,7 +40,7 @@ public abstract class Enemy extends ShootingEntity {
|
|||
if(willShoot == true){
|
||||
this.shoot();
|
||||
}
|
||||
if(this.getX() < 0-getWidth()){
|
||||
if(this.getX() < 0-this.getWidth()) {
|
||||
this.remove();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -37,7 +37,6 @@ public class EnemyBossMinion extends Enemy{
|
|||
/**
|
||||
* Custom MultiExplosion for this enemy.
|
||||
*/
|
||||
@Override
|
||||
public void explode() {
|
||||
new MultiExplosion(this.getX(), this.getY());
|
||||
}
|
||||
|
@ -45,7 +44,7 @@ public class EnemyBossMinion extends Enemy{
|
|||
@Override
|
||||
public void update() {
|
||||
super.update();
|
||||
this.setPosition(this.getX()-1, this.getY());
|
||||
this.transpose(-1, 0);
|
||||
Player player = GameScreen.getPlayer();
|
||||
if(this.getY() < player.getY()){
|
||||
this.newY += ySpeed;
|
||||
|
|
|
@ -74,8 +74,6 @@ public final class Level {
|
|||
if (Keyboard.isKeyDown(KeyEvent.VK_0)) {
|
||||
new EnemyBoss(400,400);
|
||||
}
|
||||
//Increase levelClock
|
||||
this.levelClock++;
|
||||
//Check whether the current interval is configured
|
||||
int currentIntervalIndex = this.config.getIntervalIndexByCurrentTime(this.levelClock);
|
||||
if(currentIntervalIndex == -1) return; //Nothing to do
|
||||
|
@ -105,6 +103,8 @@ public final class Level {
|
|||
}
|
||||
}
|
||||
}
|
||||
//Increase levelClock
|
||||
this.levelClock++;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -93,7 +93,7 @@ public class LevelConfig {
|
|||
*/
|
||||
public int getIntervalIndexByCurrentTime(int time) {
|
||||
for(int[] interval : this.intervalList) {
|
||||
if(interval[0] <= time && interval[1] >= time) {
|
||||
if(time >= interval[0] && time < interval[1]) {
|
||||
return this.intervalList.indexOf(interval);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue