diff --git a/android/assets/themes/dark.theme b/android/assets/themes/dark.theme index 31d38d4..acd0076 100644 --- a/android/assets/themes/dark.theme +++ b/android/assets/themes/dark.theme @@ -9,11 +9,14 @@ "c23a20ff", "956fd6ff" ], + "empty_cell": "292929ff", "cells": [ "7931bfff", "4c87aeff", "3aa853ff", "1e984dff", "2e749bff", "db5500ff", "d88109ff", "d9294dff", "ac342bff" - ] + ], + "current_score": "c83737ff", + "high_score": "d400aaff" }, "cell_texture": "basic.png" } diff --git a/android/assets/themes/default.theme b/android/assets/themes/default.theme index 77c9c34..5d3155d 100644 --- a/android/assets/themes/default.theme +++ b/android/assets/themes/default.theme @@ -9,11 +9,14 @@ "2389fcff", "d94848ff" ], + "empty_cell": "ffffffff", "cells": [ "7988bfff", "98dc53ff", "4cd4aeff", "fec63dff", "ec9548ff", "e66a82ff", "da6554ff", "57cb84ff", "5abee2ff" - ] + ], + "current_score": "ffcc00ff", + "high_score": "65d681ff" }, "cell_texture": "basic.png" } diff --git a/core/src/io/github/lonamiwebs/klooni/Theme.java b/core/src/io/github/lonamiwebs/klooni/Theme.java index 45859de..df1d2f4 100644 --- a/core/src/io/github/lonamiwebs/klooni/Theme.java +++ b/core/src/io/github/lonamiwebs/klooni/Theme.java @@ -20,7 +20,13 @@ public class Theme { private String displayName; private String name; private int price; + public Color background; + public Color emptyCell; + + public Color currentScore; + public Color highScore; + private Color[] cells; private Color[] buttons; @@ -99,6 +105,11 @@ public class Theme { buttonStyles[i].down = skin.newDrawable("button_down", buttons[i]); } + currentScore = new Color((int)Long.parseLong(colors.getString("current_score"), 16)); + highScore = new Color((int)Long.parseLong(colors.getString("high_score"), 16)); + + emptyCell = new Color((int)Long.parseLong(colors.getString("empty_cell"), 16)); + JsonValue cellColors = colors.get("cells"); cells = new Color[cellColors.size]; for (int i = 0; i < cells.length; i++) { diff --git a/core/src/io/github/lonamiwebs/klooni/game/Cell.java b/core/src/io/github/lonamiwebs/klooni/game/Cell.java index afeed1c..e904aa5 100644 --- a/core/src/io/github/lonamiwebs/klooni/game/Cell.java +++ b/core/src/io/github/lonamiwebs/klooni/game/Cell.java @@ -35,7 +35,6 @@ public class Cell { size = cellSize; empty = true; - color = Color.WHITE; vanishElapsed = Float.POSITIVE_INFINITY; } @@ -50,7 +49,8 @@ public class Cell { } void draw(SpriteBatch batch) { - draw(color, batch, pos.x, pos.y, size); + // Always query the color to the theme, because it might have changed + draw(empty ? Klooni.theme.emptyCell : color, batch, pos.x, pos.y, size); // Draw the previous vanishing cell if (vanishElapsed <= vanishLifetime) { @@ -89,8 +89,6 @@ public class Cell { // Negative time = delay, + 0.4*lifetime because elastic interpolation has that delay vanishElapsed = vanishLifetime * 0.4f - vanishDist; - - color = Color.WHITE; } boolean isEmpty() { diff --git a/core/src/io/github/lonamiwebs/klooni/game/GameLayout.java b/core/src/io/github/lonamiwebs/klooni/game/GameLayout.java index d020e66..da68f73 100644 --- a/core/src/io/github/lonamiwebs/klooni/game/GameLayout.java +++ b/core/src/io/github/lonamiwebs/klooni/game/GameLayout.java @@ -70,7 +70,7 @@ public class GameLayout { area.x, area.y, area.width * 0.5f - cupSize * 0.5f, area.height); - scorer.maxScoreLabel.setBounds( + scorer.highScoreLabel.setBounds( area.x + area.width * 0.5f + cupSize * 0.5f, area.y, area.width * 0.5f - cupSize * 0.5f, area.height); } diff --git a/core/src/io/github/lonamiwebs/klooni/game/Scorer.java b/core/src/io/github/lonamiwebs/klooni/game/Scorer.java index 3ec8f21..08ba6c5 100644 --- a/core/src/io/github/lonamiwebs/klooni/game/Scorer.java +++ b/core/src/io/github/lonamiwebs/klooni/game/Scorer.java @@ -22,11 +22,13 @@ public class Scorer { private int currentScore, maxScore; final Label currentScoreLabel; - final Label maxScoreLabel; + final Label highScoreLabel; final Texture cupTexture; final Rectangle cupArea; + private final Color cupColor; + // If the currentScore beat the maxScore, then we have a new record private boolean newRecord; @@ -43,17 +45,18 @@ public class Scorer { maxScore = Klooni.getMaxScore(); cupTexture = new Texture(Gdx.files.internal("ui/cup.png")); + cupColor = Klooni.theme.currentScore.cpy(); cupArea = new Rectangle(); Label.LabelStyle labelStyle = new Label.LabelStyle(); labelStyle.font = game.skin.getFont("font"); currentScoreLabel = new Label("0", labelStyle); - currentScoreLabel.setColor(Color.GOLD); + currentScoreLabel.setColor(Klooni.theme.currentScore); currentScoreLabel.setAlignment(Align.right); - maxScoreLabel = new Label(Integer.toString(maxScore), labelStyle); - maxScoreLabel.setColor(new Color(0x65D681FF)); + highScoreLabel = new Label(Integer.toString(maxScore), labelStyle); + highScoreLabel.setColor(Klooni.theme.highScore); layout.update(this); } @@ -108,10 +111,13 @@ public class Scorer { currentScoreLabel.setText(Integer.toString(MathUtils.round(shownScore))); } - batch.setColor(Color.GOLD); + // If we beat a new record, the cup color will linear interpolate to the high score color + cupColor.lerp(newRecord ? Klooni.theme.highScore : Klooni.theme.currentScore, 0.05f); + batch.setColor(cupColor); batch.draw(cupTexture, cupArea.x, cupArea.y, cupArea.width, cupArea.height); + currentScoreLabel.draw(batch, 1f); - maxScoreLabel.draw(batch, 1f); + highScoreLabel.draw(batch, 1f); } //endregion