From db974845eaf4792928f68ad05963a8ee2f855da3 Mon Sep 17 00:00:00 2001 From: Michael Yang Date: Sat, 17 May 2014 19:02:28 -0400 Subject: [PATCH 1/2] added overlays to modal screens --- input.js | 3 ++- main.js | 16 +++++++++------- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/input.js b/input.js index 0807461..848042a 100644 --- a/input.js +++ b/input.js @@ -9,10 +9,11 @@ keypress.register_combo({ }); keypress.register_combo({ - keys: "enter", + keys: "enter", on_keyup: function(){ if (gameState != 1) { init(); } + console.log('sweg'); }, }); diff --git a/main.js b/main.js index 60704a1..bad8c3b 100644 --- a/main.js +++ b/main.js @@ -37,10 +37,11 @@ function init() { lastGen = Date.now(); prevScore = Date.now(); nextGen = 1000; - + requestAnimFrame(animloop); } var colors = ["#e74c3c", "#f1c40f","#3498db"]; -var hexagonBackgroundColor = '#ecf0f1'; +var hexagonBackgroundColor = 'rgb(236, 240, 241)'; +var hexagonBackgroundColorClear = 'rgba(236, 240, 241, 0.5)'; var swegBlue = '#2c3e50'; //tumblr? function render() { @@ -85,13 +86,12 @@ function render() { MainClock.draw(); } -(function animloop(){ - requestAnimFrame(animloop); - +function animloop(){ if (gameState == 0) { showModal('Start!', 'Press enter to start!'); } else if (gameState == 1) { + requestAnimFrame(animloop); render(); checkGameOver(); } @@ -99,7 +99,9 @@ function render() { showModal('Game over!', score + ' pts!'); } -})(); +} +requestAnimFrame(animloop); + function drawPolygon(x, y, sides, radius, theta, color) { // can make more elegant, reduce redundancy, fix readability ctx.fillStyle = color; @@ -132,7 +134,7 @@ function showModal(text, secondaryText) { var buttonSize = 150; var fontSizeLarge = 50; var fontSizeSmall = 25; - drawPolygon(canvas.width / 2, canvas.height / 2, 6, canvas.width / 2, 30, hexagonBackgroundColor); + drawPolygon(canvas.width / 2, canvas.height / 2, 6, canvas.width / 2, 30, hexagonBackgroundColorClear); ctx.fillStyle = swegBlue; // drawPolygon(canvas.width / 2, canvas.height / 2, 6, buttonSize, 30, swegBlue); ctx.font = fontSizeLarge+'px "Roboto"'; From 79462e405e5d05b518a31b13e46d1feaa548754d Mon Sep 17 00:00:00 2001 From: Michael Yang Date: Sat, 17 May 2014 19:06:51 -0400 Subject: [PATCH 2/2] edited end screen message --- main.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/main.js b/main.js index bad8c3b..310c319 100644 --- a/main.js +++ b/main.js @@ -96,7 +96,7 @@ function animloop(){ checkGameOver(); } else if (gameState == 2) { - showModal('Game over!', score + ' pts!'); + showModal('Game over: '+score+' pts!', 'Press enter to restart!'); } }