From 2ed07b430a0386e380b8aa658f3d3ddfc63122e7 Mon Sep 17 00:00:00 2001 From: Jan Philipp Timme Date: Tue, 25 Nov 2014 14:18:10 +0100 Subject: [PATCH] Move levelClock++ to the end, adjust interval checks. --- src/de/teamteamteam/spacescooter/entity/LivingEntity.java | 3 +-- src/de/teamteamteam/spacescooter/entity/enemy/Enemy.java | 2 +- .../spacescooter/entity/enemy/EnemyBossMinion.java | 5 ++--- src/de/teamteamteam/spacescooter/level/Level.java | 4 ++-- src/de/teamteamteam/spacescooter/level/LevelConfig.java | 2 +- 5 files changed, 7 insertions(+), 9 deletions(-) diff --git a/src/de/teamteamteam/spacescooter/entity/LivingEntity.java b/src/de/teamteamteam/spacescooter/entity/LivingEntity.java index 2b76b7f..1e321ea 100644 --- a/src/de/teamteamteam/spacescooter/entity/LivingEntity.java +++ b/src/de/teamteamteam/spacescooter/entity/LivingEntity.java @@ -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 diff --git a/src/de/teamteamteam/spacescooter/entity/enemy/Enemy.java b/src/de/teamteamteam/spacescooter/entity/enemy/Enemy.java index b710091..f7649af 100644 --- a/src/de/teamteamteam/spacescooter/entity/enemy/Enemy.java +++ b/src/de/teamteamteam/spacescooter/entity/enemy/Enemy.java @@ -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(); } } diff --git a/src/de/teamteamteam/spacescooter/entity/enemy/EnemyBossMinion.java b/src/de/teamteamteam/spacescooter/entity/enemy/EnemyBossMinion.java index c6b1731..6ef4a5e 100644 --- a/src/de/teamteamteam/spacescooter/entity/enemy/EnemyBossMinion.java +++ b/src/de/teamteamteam/spacescooter/entity/enemy/EnemyBossMinion.java @@ -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); } diff --git a/src/de/teamteamteam/spacescooter/level/Level.java b/src/de/teamteamteam/spacescooter/level/Level.java index e99f5d4..ee9fe4c 100644 --- a/src/de/teamteamteam/spacescooter/level/Level.java +++ b/src/de/teamteamteam/spacescooter/level/Level.java @@ -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++; } /** diff --git a/src/de/teamteamteam/spacescooter/level/LevelConfig.java b/src/de/teamteamteam/spacescooter/level/LevelConfig.java index 433f1f3..acd64fa 100644 --- a/src/de/teamteamteam/spacescooter/level/LevelConfig.java +++ b/src/de/teamteamteam/spacescooter/level/LevelConfig.java @@ -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); } }