Move levelClock++ to the end, adjust interval checks.

This commit is contained in:
Jan Philipp Timme 2014-11-25 14:18:10 +01:00
parent 52f038d4c4
commit 2ed07b430a
5 changed files with 7 additions and 9 deletions

View File

@ -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

View File

@ -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();
}
}

View File

@ -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,12 +44,12 @@ 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;
this.setPosition(this.getX(), (int) newY);
}else if(this.getY() > player.getY()){
} else if(this.getY() > player.getY()) {
this.newY -= ySpeed;
this.setPosition(this.getX(), (int) newY);
}

View File

@ -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++;
}
/**

View File

@ -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);
}
}