added drawKey(key, x, y) to draw any key at any given (x,y)

This commit is contained in:
meadowstream 2014-07-03 01:24:35 -04:00
parent 216da7ba81
commit 01de2bd6c5

View file

@ -32,7 +32,9 @@ function render() {
}
MainClock.draw();
drawScoreboard();
if (gameState ==1 || gameState ==-1 || gameState === 0) {
drawScoreboard();
}
for (i = 0; i < MainClock.texts.length; i++) {
var alive = MainClock.texts[i].draw();
@ -46,3 +48,33 @@ function render() {
settings.hexWidth = settings.baseHexWidth * settings.scale;
settings.blockHeight = settings.baseBlockHeight * settings.scale;
}
function drawKey(key, x, y) {
ctx.save();
ctx.scale(settings.scale - .3,settings.scale - .3);
ctx.fillStyle = '#2c3e50';
ctx.strokeStyle = '#2c3e50';
ctx.lineWidth = 5;
ctx.rect(x + 2.5, y + 2.5, 45, 45);
ctx.stroke();
switch (key) {
case "left":
ctx.translate(x + 24, y + 16.5);
ctx.rotate(3.14159);
ctx.font = "25px Fontawesome";
ctx.fillText("", 0, 0);
break;
case "right":
ctx.font = "25px Fontawesome";
ctx.fillText("", x + 27, y + 34.5);
break;
default:
ctx.font = "40px Roboto";
ctx.fillText(key, x + 25 , y + 39.5);
}
ctx.restore();
}