Add round clear flashing, closes #5
This commit is contained in:
parent
6bfe740416
commit
d21a4b8c1d
BIN
core/assets/level_background_win.png
Normal file
BIN
core/assets/level_background_win.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 7.9 KiB |
@ -38,6 +38,7 @@ public class Assets {
|
|||||||
|
|
||||||
public void loadAssets() {
|
public void loadAssets() {
|
||||||
manager.load("level_background.png", Texture.class);
|
manager.load("level_background.png", Texture.class);
|
||||||
|
manager.load("level_background_win.png", Texture.class);
|
||||||
manager.load("menu_background.png", Texture.class);
|
manager.load("menu_background.png", Texture.class);
|
||||||
manager.load("logo.png", Texture.class);
|
manager.load("logo.png", Texture.class);
|
||||||
|
|
||||||
@ -105,6 +106,10 @@ public class Assets {
|
|||||||
return manager.get("level_background.png", Texture.class);
|
return manager.get("level_background.png", Texture.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Texture getLevelWinBackground() {
|
||||||
|
return manager.get("level_background_win.png", Texture.class);
|
||||||
|
}
|
||||||
|
|
||||||
public Texture getMenuBackground() {
|
public Texture getMenuBackground() {
|
||||||
return manager.get("menu_background.png", Texture.class);
|
return manager.get("menu_background.png", Texture.class);
|
||||||
}
|
}
|
||||||
|
@ -34,7 +34,7 @@ public class PlayState extends LevelState {
|
|||||||
Direction.DOWN,
|
Direction.DOWN,
|
||||||
};
|
};
|
||||||
|
|
||||||
private Texture levelBackground;
|
private Texture levelBackground, winBackground;
|
||||||
private BitmapFont font;
|
private BitmapFont font;
|
||||||
|
|
||||||
private TextureRegion lifeSprite;
|
private TextureRegion lifeSprite;
|
||||||
@ -59,6 +59,8 @@ public class PlayState extends LevelState {
|
|||||||
private float newGameTimer;
|
private float newGameTimer;
|
||||||
private float deathTimer;
|
private float deathTimer;
|
||||||
private float pointsTimer;
|
private float pointsTimer;
|
||||||
|
private float roundClearedTimer;
|
||||||
|
|
||||||
public float frightTimer;
|
public float frightTimer;
|
||||||
public float secondsSinceLastDot;
|
public float secondsSinceLastDot;
|
||||||
|
|
||||||
@ -82,6 +84,7 @@ public class PlayState extends LevelState {
|
|||||||
@Override
|
@Override
|
||||||
public void setup() {
|
public void setup() {
|
||||||
levelBackground = game.assets.getLevelBackground();
|
levelBackground = game.assets.getLevelBackground();
|
||||||
|
winBackground = game.assets.getLevelWinBackground();
|
||||||
font = game.assets.getFont();
|
font = game.assets.getFont();
|
||||||
lifeSprite = game.assets.pacman[2][1];
|
lifeSprite = game.assets.pacman[2][1];
|
||||||
Gdx.input.setInputProcessor(new Controller());
|
Gdx.input.setInputProcessor(new Controller());
|
||||||
@ -91,7 +94,6 @@ public class PlayState extends LevelState {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void render() {
|
public void render() {
|
||||||
game.batch.draw(levelBackground, 0, 16);
|
|
||||||
level.render(0, 16);
|
level.render(0, 16);
|
||||||
|
|
||||||
game.assets.getFont().setColor(Color.WHITE);
|
game.assets.getFont().setColor(Color.WHITE);
|
||||||
@ -106,6 +108,14 @@ public class PlayState extends LevelState {
|
|||||||
pacman.render(game.batch, 0, 16);
|
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) {
|
if (pacman.alive && newGameTimer <= 0) {
|
||||||
for (Ghost ghost : ghosts) {
|
for (Ghost ghost : ghosts) {
|
||||||
if (pointsTimer > 0 && ghost == lastGhostCaptured) {
|
if (pointsTimer > 0 && ghost == lastGhostCaptured) {
|
||||||
@ -147,6 +157,14 @@ public class PlayState extends LevelState {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (roundClearedTimer > 0) {
|
||||||
|
roundClearedTimer -= dt;
|
||||||
|
if (roundClearedTimer <= 0) {
|
||||||
|
newRound();
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (gameOverTimer > 0) {
|
if (gameOverTimer > 0) {
|
||||||
gameOverTimer -= dt;
|
gameOverTimer -= dt;
|
||||||
if (gameOverTimer <= 0) {
|
if (gameOverTimer <= 0) {
|
||||||
@ -363,7 +381,7 @@ public class PlayState extends LevelState {
|
|||||||
secondsSinceLastDot = 0;
|
secondsSinceLastDot = 0;
|
||||||
|
|
||||||
if (pelletCount == 0) {
|
if (pelletCount == 0) {
|
||||||
newRound();
|
roundClearedTimer = 3f;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user