diff --git a/core/src/io/github/lonamiwebs/klooni/game/BaseScorer.java b/core/src/io/github/lonamiwebs/klooni/game/BaseScorer.java index 65e1562..03443a0 100644 --- a/core/src/io/github/lonamiwebs/klooni/game/BaseScorer.java +++ b/core/src/io/github/lonamiwebs/klooni/game/BaseScorer.java @@ -15,7 +15,7 @@ public abstract class BaseScorer implements BinSerializable { //region Members - final Label leftLabel; + final Label currentScoreLabel; final Label highScoreLabel; final Texture cupTexture; @@ -36,8 +36,8 @@ public abstract class BaseScorer implements BinSerializable { Label.LabelStyle labelStyle = new Label.LabelStyle(); labelStyle.font = game.skin.getFont("font"); - leftLabel = new Label("0", labelStyle); - leftLabel.setAlignment(Align.right); + currentScoreLabel = new Label("0", labelStyle); + currentScoreLabel.setAlignment(Align.right); highScoreLabel = new Label(Integer.toString(highScore), labelStyle); @@ -89,8 +89,8 @@ public abstract class BaseScorer implements BinSerializable { batch.setColor(cupColor); batch.draw(cupTexture, cupArea.x, cupArea.y, cupArea.width, cupArea.height); - leftLabel.setColor(Klooni.theme.currentScore); - leftLabel.draw(batch, 1f); + currentScoreLabel.setColor(Klooni.theme.currentScore); + currentScoreLabel.draw(batch, 1f); highScoreLabel.setColor(Klooni.theme.highScore); highScoreLabel.draw(batch, 1f); diff --git a/core/src/io/github/lonamiwebs/klooni/game/GameLayout.java b/core/src/io/github/lonamiwebs/klooni/game/GameLayout.java index 7330df3..5e71014 100644 --- a/core/src/io/github/lonamiwebs/klooni/game/GameLayout.java +++ b/core/src/io/github/lonamiwebs/klooni/game/GameLayout.java @@ -3,6 +3,7 @@ package io.github.lonamiwebs.klooni.game; import com.badlogic.gdx.Gdx; import com.badlogic.gdx.math.Rectangle; +import com.badlogic.gdx.scenes.scene2d.ui.Label; import io.github.lonamiwebs.klooni.actors.Band; import io.github.lonamiwebs.klooni.actors.ThemeCard; @@ -16,7 +17,7 @@ public class GameLayout { //region Members private float screenWidth, marginWidth, availableWidth; - private float scoreHeight, boardHeight, pieceHolderHeight, themeCardHeight; + private float screenHeight, logoHeight, scoreHeight, boardHeight, pieceHolderHeight, themeCardHeight; //endregion @@ -32,14 +33,14 @@ public class GameLayout { private void calculate() { screenWidth = Gdx.graphics.getWidth(); - float screenHeight = Gdx.graphics.getHeight(); + screenHeight = Gdx.graphics.getHeight(); // Widths marginWidth = screenWidth * 0.05f; availableWidth = screenWidth - marginWidth * 2f; // Heights - // logoHeight = screenHeight * 0.10f; // Unused + logoHeight = screenHeight * 0.10f; scoreHeight = screenHeight * 0.15f; boardHeight = screenHeight * 0.50f; pieceHolderHeight = screenHeight * 0.25f; @@ -66,7 +67,7 @@ public class GameLayout { area.x + area.width * 0.5f - cupSize * 0.5f, area.y, cupSize, cupSize); - scorer.leftLabel.setBounds( + scorer.currentScoreLabel.setBounds( area.x, area.y, area.width * 0.5f - cupSize * 0.5f, area.height); @@ -75,6 +76,11 @@ public class GameLayout { area.width * 0.5f - cupSize * 0.5f, area.height); } + // Special case, we want to position the label on top of the cup + void updateTimeLeftLabel(Label timeLeftLabel) { + timeLeftLabel.setBounds(0, screenHeight - logoHeight, screenWidth, logoHeight); + } + void update(Board board) { // We can't leave our area, so pick the minimum between available // height and width to determine an appropriated cell size diff --git a/core/src/io/github/lonamiwebs/klooni/game/Scorer.java b/core/src/io/github/lonamiwebs/klooni/game/Scorer.java index d980b83..854ff64 100644 --- a/core/src/io/github/lonamiwebs/klooni/game/Scorer.java +++ b/core/src/io/github/lonamiwebs/klooni/game/Scorer.java @@ -72,7 +72,7 @@ public class Scorer extends BaseScorer implements BinSerializable { int roundShown = MathUtils.round(shownScore); if (roundShown != currentScore) { shownScore = Interpolation.linear.apply(shownScore, currentScore, 0.1f); - leftLabel.setText(Integer.toString(MathUtils.round(shownScore))); + currentScoreLabel.setText(Integer.toString(MathUtils.round(shownScore))); } super.draw(batch); } diff --git a/core/src/io/github/lonamiwebs/klooni/game/TimeScorer.java b/core/src/io/github/lonamiwebs/klooni/game/TimeScorer.java index ca64ef6..a062093 100644 --- a/core/src/io/github/lonamiwebs/klooni/game/TimeScorer.java +++ b/core/src/io/github/lonamiwebs/klooni/game/TimeScorer.java @@ -2,6 +2,8 @@ package io.github.lonamiwebs.klooni.game; import com.badlogic.gdx.graphics.g2d.SpriteBatch; import com.badlogic.gdx.math.MathUtils; +import com.badlogic.gdx.scenes.scene2d.ui.Label; +import com.badlogic.gdx.utils.Align; import com.badlogic.gdx.utils.TimeUtils; import java.io.DataInputStream; @@ -15,6 +17,8 @@ public class TimeScorer extends BaseScorer implements BinSerializable { //region Members + private final Label timeLeftLabel; + private long startTime; private int highScoreTime; @@ -37,6 +41,12 @@ public class TimeScorer extends BaseScorer implements BinSerializable { super(game, layout, Klooni.getMaxTimeScore()); highScoreTime = Klooni.getMaxTimeScore(); + Label.LabelStyle labelStyle = new Label.LabelStyle(); + labelStyle.font = game.skin.getFont("font"); + timeLeftLabel = new Label("", labelStyle); + timeLeftLabel.setAlignment(Align.center); + layout.updateTimeLeftLabel(timeLeftLabel); + startTime = TimeUtils.nanoTime(); deadTime = startTime + START_TIME; @@ -111,10 +121,13 @@ public class TimeScorer extends BaseScorer implements BinSerializable { @Override public void draw(SpriteBatch batch) { - int timeLeft = pausedTimeLeft < 0 ? getTimeLeft() : pausedTimeLeft; - leftLabel.setText(Integer.toString(timeLeft)); - + currentScoreLabel.setText(Integer.toString(getCurrentScore())); super.draw(batch); + + int timeLeft = pausedTimeLeft < 0 ? getTimeLeft() : pausedTimeLeft; + timeLeftLabel.setText(Integer.toString(timeLeft)); + timeLeftLabel.setColor(Klooni.theme.currentScore); + timeLeftLabel.draw(batch, 1f); } //endregion