added support for scores in the range of [0, 999999999]

This commit is contained in:
lengstrom 2014-08-01 21:35:20 -04:00
parent 85b4c336fa
commit 8d9530750f

View file

@ -24,22 +24,32 @@ function drawScoreboard() {
}
ctx.globalAlpha = textOpacity;
var scoreSize = 50;
var scoreString = String(score);
if (scoreString.length == 6) {
scoreSize = 43;
} else if (scoreString.length == 7) {
scoreSize = 35;
} else if (scoreString.length == 8) {
scoreSize = 31;
} else if (scoreString.length == 9) {
scoreSize = 27;
}
if (gameState === 0) {
renderText(trueCanvas.width / 2 + gdx + 6 * settings.scale, trueCanvas.height / 2 + gdy, 60, "rgb(236, 240, 241)", String.fromCharCode("0xf04b"), 'px FontAwesome');
renderText(trueCanvas.width / 2 + gdx + 6 * settings.scale, trueCanvas.height / 2 + gdy - 170 * settings.scale, 150, "#2c3e50", "Hextris");
renderText(trueCanvas.width / 2 + gdx + 5 * settings.scale, trueCanvas.height / 2 + gdy + 100 * settings.scale, 20, "rgb(44,62,80)", 'Play!');
}
else if(gameState!=0 && textOpacity>0){
} else if (gameState != 0 && textOpacity > 0) {
textOpacity -= 0.05;
renderText(trueCanvas.width / 2 + gdx + 6 * settings.scale, trueCanvas.height / 2 + gdy, 60, "rgb(236, 240, 241)", String.fromCharCode("0xf04b"), 'px FontAwesome');
renderText(trueCanvas.width / 2 + gdx + 6 * settings.scale, trueCanvas.height / 2 + gdy - 170 * settings.scale, 150, "#2c3e50", "Hextris");
renderText(trueCanvas.width / 2 + gdx + 5 * settings.scale, trueCanvas.height / 2 + gdy + 100 * settings.scale, 20, "rgb(44,62,80)", 'Play!');
ctx.globalAlpha = scoreOpacity;
renderText(trueCanvas.width/2+ gdx, trueCanvas.height/2+ gdy, 50, "rgb(236, 240, 241)", score);
}
else {
renderText(trueCanvas.width / 2 + gdx, trueCanvas.height / 2 + gdy, scoreSize, "rgb(236, 240, 241)", score);
} else {
ctx.globalAlpha = scoreOpacity;
renderText(trueCanvas.width/2+ gdx, trueCanvas.height/2+ gdy, 50, "rgb(236, 240, 241)", score);
renderText(trueCanvas.width / 2 + gdx, trueCanvas.height / 2 + gdy, scoreSize, "rgb(236, 240, 241)", score);
}
ctx.globalAlpha = 1;
@ -75,8 +85,7 @@ function drawPolygon(x, y, sides, radius, theta, fillColor, lineWidth, lineColor
function toggleClass(element, active) {
if ($(element).hasClass(active)) {
$(element).removeClass(active);
}
else {
} else {
$(element).addClass(active);
}
}
@ -161,7 +170,9 @@ function setMainMenu() {
}
function hideText() {
$("#overlay").fadeOut("1000",function(){$("#overlay").html("");})
$("#overlay").fadeOut("1000", function() {
$("#overlay").html("");
})
}
function gameOverDisplay() {
@ -195,8 +206,7 @@ function pause(o) {
gameState = prevGameState;
}, 200)
}
else if(gameState != -2 && gameState !== 0 && gameState !== 2) {
} else if (gameState != -2 && gameState !== 0 && gameState !== 2) {
$('.helpText').fadeIn(200, 'linear');
showbottombar();
if (message == 'paused') {