Add round clear flashing, closes #5

This commit is contained in:
Matt Low 2020-01-02 02:29:19 +04:00
parent 6bfe740416
commit d21a4b8c1d
3 changed files with 26 additions and 3 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.9 KiB

View File

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

View File

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