diff --git a/core/assets/level_background_win.png b/core/assets/level_background_win.png new file mode 100644 index 0000000..1eb0f8f Binary files /dev/null and b/core/assets/level_background_win.png differ diff --git a/core/src/com/me/pacman/Assets.java b/core/src/com/me/pacman/Assets.java index 358a125..fb985c3 100644 --- a/core/src/com/me/pacman/Assets.java +++ b/core/src/com/me/pacman/Assets.java @@ -38,6 +38,7 @@ public class Assets { public void loadAssets() { manager.load("level_background.png", Texture.class); + manager.load("level_background_win.png", Texture.class); manager.load("menu_background.png", Texture.class); manager.load("logo.png", Texture.class); @@ -105,6 +106,10 @@ public class Assets { return manager.get("level_background.png", Texture.class); } + public Texture getLevelWinBackground() { + return manager.get("level_background_win.png", Texture.class); + } + public Texture getMenuBackground() { return manager.get("menu_background.png", Texture.class); } diff --git a/core/src/com/me/pacman/state/PlayState.java b/core/src/com/me/pacman/state/PlayState.java index c0f704d..ee755ac 100644 --- a/core/src/com/me/pacman/state/PlayState.java +++ b/core/src/com/me/pacman/state/PlayState.java @@ -34,7 +34,7 @@ public class PlayState extends LevelState { Direction.DOWN, }; - private Texture levelBackground; + private Texture levelBackground, winBackground; private BitmapFont font; private TextureRegion lifeSprite; @@ -59,6 +59,8 @@ public class PlayState extends LevelState { private float newGameTimer; private float deathTimer; private float pointsTimer; + private float roundClearedTimer; + public float frightTimer; public float secondsSinceLastDot; @@ -82,6 +84,7 @@ public class PlayState extends LevelState { @Override public void setup() { levelBackground = game.assets.getLevelBackground(); + winBackground = game.assets.getLevelWinBackground(); font = game.assets.getFont(); lifeSprite = game.assets.pacman[2][1]; Gdx.input.setInputProcessor(new Controller()); @@ -91,7 +94,6 @@ public class PlayState extends LevelState { @Override public void render() { - game.batch.draw(levelBackground, 0, 16); level.render(0, 16); game.assets.getFont().setColor(Color.WHITE); @@ -106,6 +108,14 @@ public class PlayState extends LevelState { pacman.render(game.batch, 0, 16); } + if (roundClearedTimer > 0 && roundClearedTimer <= 2) { + // draw flashing level background + game.batch.draw((int) (roundClearedTimer * 4) % 2 == 0? levelBackground : winBackground, 0, 16); + return; + } else { + game.batch.draw(levelBackground, 0, 16); + } + if (pacman.alive && newGameTimer <= 0) { for (Ghost ghost : ghosts) { if (pointsTimer > 0 && ghost == lastGhostCaptured) { @@ -147,6 +157,14 @@ public class PlayState extends LevelState { return; } + if (roundClearedTimer > 0) { + roundClearedTimer -= dt; + if (roundClearedTimer <= 0) { + newRound(); + } + return; + } + if (gameOverTimer > 0) { gameOverTimer -= dt; if (gameOverTimer <= 0) { @@ -363,7 +381,7 @@ public class PlayState extends LevelState { secondsSinceLastDot = 0; if (pelletCount == 0) { - newRound(); + roundClearedTimer = 3f; } }