diff --git a/src/de/teamteamteam/spacescooter/background/Background.java b/src/de/teamteamteam/spacescooter/background/Background.java index 5407c49..cf957d2 100644 --- a/src/de/teamteamteam/spacescooter/background/Background.java +++ b/src/de/teamteamteam/spacescooter/background/Background.java @@ -1,23 +1,11 @@ package de.teamteamteam.spacescooter.background; -import java.util.ArrayList; - import de.teamteamteam.spacescooter.entity.Entity; public abstract class Background extends Entity { - public static ArrayList backgrounds = null; - - /** - * We need to initialize the ArrayList, so the EntityUpdateThread won't beat us. - */ - static { - Background.backgrounds = new ArrayList(); - } - public Background(int x, int y) { super(x, y); - Background.backgrounds.add(this); } } diff --git a/src/de/teamteamteam/spacescooter/control/Keyboard.java b/src/de/teamteamteam/spacescooter/control/Keyboard.java index 145d15c..cb0d5b4 100644 --- a/src/de/teamteamteam/spacescooter/control/Keyboard.java +++ b/src/de/teamteamteam/spacescooter/control/Keyboard.java @@ -70,7 +70,13 @@ public class Keyboard implements KeyListener { Keyboard.listener.remove(listener); } - + /** + * Make sure we only iterate over copies due to possible concurrent modification. + * This method returns a copy of the listener list. + */ + public ArrayList getListener() { + return new ArrayList(Keyboard.listener); + } /** * KeyListener method. * Registers the pressed key and passes the event on to registered listeners. diff --git a/src/de/teamteamteam/spacescooter/entity/Player.java b/src/de/teamteamteam/spacescooter/entity/Player.java index c80ccbc..49ea7bb 100644 --- a/src/de/teamteamteam/spacescooter/entity/Player.java +++ b/src/de/teamteamteam/spacescooter/entity/Player.java @@ -30,7 +30,6 @@ public class Player extends ShootingEntity implements KeyboardListener { } public void update() { - super.update(); if(this.canMove) { super.update(); int off = 3; diff --git a/src/de/teamteamteam/spacescooter/entity/explosion/Explosion.java b/src/de/teamteamteam/spacescooter/entity/explosion/Explosion.java index 7fd1a4e..12ea650 100644 --- a/src/de/teamteamteam/spacescooter/entity/explosion/Explosion.java +++ b/src/de/teamteamteam/spacescooter/entity/explosion/Explosion.java @@ -58,7 +58,7 @@ public class Explosion extends Entity { */ public void update() { this.timeToLive--; - if(this.timeToLive == 0) this.remove(); + if(this.timeToLive <= 0) this.remove(); if(this.count > 0 && this.timeToLive % this.count == 0) { new Explosion(this.getX() + (int) (this.width * this.random.nextDouble()), this.getY() + (int) (this.height * this.random.nextDouble())); this.count--; diff --git a/src/de/teamteamteam/spacescooter/screen/GamePausedScreen.java b/src/de/teamteamteam/spacescooter/screen/GamePausedScreen.java index de1a889..1cf3100 100644 --- a/src/de/teamteamteam/spacescooter/screen/GamePausedScreen.java +++ b/src/de/teamteamteam/spacescooter/screen/GamePausedScreen.java @@ -91,7 +91,8 @@ public class GamePausedScreen extends Screen { this.parent.setOverlay(null); break; case 1: - this.parent.setOverlay(new MainMenuScreen(this.parent)); + //Replace our parents (the game) parent (the SuperScreen) overlay. + this.parent.parent.setOverlay(new MainMenuScreen(this.parent.parent)); break; } }