Skip to content

Commit

Permalink
[fixed] always show advantage/disadvantage
Browse files Browse the repository at this point in the history
[add] advantage label's palettized color is green until it reaches 0, then
it start warming up
  • Loading branch information
manuelbua committed Dec 2, 2012
1 parent 6437f41 commit 3b95098
Showing 1 changed file with 6 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,8 @@ public void render (SpriteBatch batch, float cameraZoom) {
float a = 0.25f;

playerToTarget = AMath.fixup(progressval - progressTargetVal);
playerToTarget = AMath.fixup(progressval - progressTargetVal);
lblAdvantage.setString(Math.round(distPlayer - distGhost) + " mt");

if (distPlayer > 0) {
if (!advantageShown) {
Expand All @@ -129,10 +131,6 @@ public void render (SpriteBatch batch, float cameraZoom) {
// Gdx.app.log("", "show");
}

playerToTarget = AMath.fixup(progressval - progressTargetVal);

lblAdvantage.setString(Math.round(distPlayer - distGhost) + " mt");

} else if (advantageShown) {
advantageShown = false;
lblAdvantage.queueHide(1000);
Expand All @@ -141,15 +139,16 @@ public void render (SpriteBatch batch, float cameraZoom) {

// advantage/disadvantage
float dist = MathUtils.clamp(playerToTarget * 8, -1, 1);
Color advantageColor = ColorUtils.paletteRYG(dist + 0.7f, 1f);
float ndist = (dist + 1) * 0.5f;
Color advantageColor = ColorUtils.paletteRYG(ndist * 2, 1f);

float timeFactor = URacer.Game.getTimeModFactor() * 0.3f;

lblAdvantage.setColor(advantageColor);
lblAdvantage.setAlpha(a * 2);
lblAdvantage.setScale(cameraZoom * (0.6f + 0.3f * (dist + 0.7f)));
lblAdvantage.setScale(cameraZoom * (1f - 0.4f * (1 - ndist)));
lblAdvantage.setPosition(position.x, position.y - cameraZoom * Convert.scaledPixels(90) - Convert.scaledPixels(90)
* timeFactor * cameraZoom - Convert.scaledPixels(10) * (dist + 0.7f) * cameraZoom);
* timeFactor * cameraZoom - Convert.scaledPixels(8) * cameraZoom);
lblAdvantage.render(batch);

float s = 1f + timeFactor;
Expand Down

0 comments on commit 3b95098

Please sign in to comment.