From e87ec69e975f871f0272ce92af38732534d7817b Mon Sep 17 00:00:00 2001 From: Jan Philipp Timme Date: Tue, 4 Nov 2014 19:46:19 +0100 Subject: [PATCH] Actually have the entity take care of adding it to the current screen. Whoopsie. --- src/de/teamteamteam/spacescooter/entity/Entity.java | 1 + .../spacescooter/screen/GameOverScreen.java | 5 ++--- .../spacescooter/screen/GamePausedScreen.java | 5 ++--- .../spacescooter/screen/GameScreen.java | 12 ++++++------ .../spacescooter/screen/MainMenuScreen.java | 13 ++++++------- 5 files changed, 17 insertions(+), 19 deletions(-) diff --git a/src/de/teamteamteam/spacescooter/entity/Entity.java b/src/de/teamteamteam/spacescooter/entity/Entity.java index a53848c..35dd1bd 100644 --- a/src/de/teamteamteam/spacescooter/entity/Entity.java +++ b/src/de/teamteamteam/spacescooter/entity/Entity.java @@ -24,6 +24,7 @@ public abstract class Entity implements Updateable, Paintable { public Entity(int x, int y) { this.x = x; this.y = y; + Screen.currentScreen.addEntity(this); } public int getX() { diff --git a/src/de/teamteamteam/spacescooter/screen/GameOverScreen.java b/src/de/teamteamteam/spacescooter/screen/GameOverScreen.java index 231bafc..08e1a7f 100644 --- a/src/de/teamteamteam/spacescooter/screen/GameOverScreen.java +++ b/src/de/teamteamteam/spacescooter/screen/GameOverScreen.java @@ -28,11 +28,10 @@ public class GameOverScreen extends Screen { public GameOverScreen(Screen parent) { super(parent); this.img = Loader.getBufferedImageByFilename("images/pausebackground.png"); - this.entities.add(new Button(GameConfig.windowWidth/2-125, 300)); - this.entities.add(new Button(GameConfig.windowWidth/2-125, 400)); + new Button(GameConfig.windowWidth/2-125, 300); + new Button(GameConfig.windowWidth/2-125, 400); player = new Player(GameConfig.windowWidth/2-170, 309); player.setCanMove(false); - this.entities.add(player); } @Override diff --git a/src/de/teamteamteam/spacescooter/screen/GamePausedScreen.java b/src/de/teamteamteam/spacescooter/screen/GamePausedScreen.java index 1601897..b6703a0 100644 --- a/src/de/teamteamteam/spacescooter/screen/GamePausedScreen.java +++ b/src/de/teamteamteam/spacescooter/screen/GamePausedScreen.java @@ -28,11 +28,10 @@ public class GamePausedScreen extends Screen { public GamePausedScreen(Screen parent) { super(parent); this.img = Loader.getBufferedImageByFilename("images/pausebackground.png"); - this.entities.add(new Button(GameConfig.windowWidth/2-125, 300)); - this.entities.add(new Button(GameConfig.windowWidth/2-125, 400)); + new Button(GameConfig.windowWidth/2-125, 300); + new Button(GameConfig.windowWidth/2-125, 400); player = new Player(GameConfig.windowWidth/2-170, 309); player.setCanMove(false); - this.entities.add(player); } @Override diff --git a/src/de/teamteamteam/spacescooter/screen/GameScreen.java b/src/de/teamteamteam/spacescooter/screen/GameScreen.java index da8f945..a19547f 100644 --- a/src/de/teamteamteam/spacescooter/screen/GameScreen.java +++ b/src/de/teamteamteam/spacescooter/screen/GameScreen.java @@ -26,12 +26,12 @@ public class GameScreen extends Screen { points.add(new Point(300,300)); points.add(new Point(600,100)); points.add(new Point(0,500)); - this.entities.add(new StarBackground(0, 0)); - this.entities.add(new Player(200, 300)); - this.entities.add(new HealthBar(10, 10)); - this.entities.add(new EnemyFour(800, 400, points)); - this.entities.add(new EnemyThree(650, 300)); - this.entities.add(new EnemyThree(450, 100)); + new StarBackground(0, 0); + new Player(200, 300); + new HealthBar(10, 10); + new EnemyFour(800, 400, points); + new EnemyThree(650, 300); + new EnemyThree(450, 100); } @Override diff --git a/src/de/teamteamteam/spacescooter/screen/MainMenuScreen.java b/src/de/teamteamteam/spacescooter/screen/MainMenuScreen.java index 05107e5..3a6c311 100644 --- a/src/de/teamteamteam/spacescooter/screen/MainMenuScreen.java +++ b/src/de/teamteamteam/spacescooter/screen/MainMenuScreen.java @@ -27,15 +27,14 @@ public class MainMenuScreen extends Screen { public MainMenuScreen(Screen parent) { super(parent); - this.entities.add(new StarBackground(0, 0)); - this.entities.add(new Button(GameConfig.windowWidth/2-125, 200)); - this.entities.add(new Button(GameConfig.windowWidth/2-125, 275)); - this.entities.add(new Button(GameConfig.windowWidth/2-125, 350)); - this.entities.add(new Button(GameConfig.windowWidth/2-125, 425)); - this.entities.add(new Button(GameConfig.windowWidth/2-125, 500)); + new StarBackground(0, 0); + new Button(GameConfig.windowWidth/2-125, 200); + new Button(GameConfig.windowWidth/2-125, 275); + new Button(GameConfig.windowWidth/2-125, 350); + new Button(GameConfig.windowWidth/2-125, 425); + new Button(GameConfig.windowWidth/2-125, 500); player = new Player(GameConfig.windowWidth/2-170, 209); player.setCanMove(false); - this.entities.add(player); } @Override