From eb84ceea276de3f3d2c98bb1f17c9525edc7be42 Mon Sep 17 00:00:00 2001 From: Garrett Finucane Date: Sat, 31 May 2014 11:13:40 -0400 Subject: [PATCH] html pause --- index.html | 2 ++ js/input.js | 25 +++++++++++++++++++------ js/main.js | 4 +--- style.css | 47 ++++++++++++++++++++++++++++++++++++++++------- 4 files changed, 62 insertions(+), 16 deletions(-) diff --git a/index.html b/index.html index c7b5ee7..d2f10c9 100644 --- a/index.html +++ b/index.html @@ -37,6 +37,7 @@ } #canvas { + transition: all 0.5s ease; position: absolute; left:0; right:0; @@ -100,6 +101,7 @@

?
+
diff --git a/js/input.js b/js/input.js index ceeb66d..1e772a3 100644 --- a/js/input.js +++ b/js/input.js @@ -1,18 +1,31 @@ var prevGameState; -function pause(x,o) { - if(x === undefined){x=true} +var messages = { + 'paused':"
Paused
\ +
\ +
Press p to resume
" +} +function pause(x,o,message) { + + if(x === undefined){x=true} + message = 'paused'; + var c = document.getElementById("canvas"); + var pt = document.getElementById("overlay"); if (gameState == -1 ) { - if(showingHelp && !o){return;} + if(showingHelp && !o){return;} + c.className = ''; + pt.className = 'faded'; gameState = prevGameState; requestAnimFrame(animLoop); - pauseText = true; + } else if(gameState != -2 && gameState != 0) { + c.className = "blur"; + pt.className = ''; + pt.innerHTML = messages[message]; prevGameState = gameState; gameState = -1; - pauseText = x; } - } +} diff --git a/js/main.js b/js/main.js index 28d52ed..53b3aee 100644 --- a/js/main.js +++ b/js/main.js @@ -268,9 +268,7 @@ function animLoop() { render(); } else if (gameState == -1) { - if(pauseText){ - showModal('Paused!', 'Press "P" to continue.'); - } + } else if (gameState == 2) { requestAnimFrame(animLoop); diff --git a/style.css b/style.css index 135fc2f..f47ced4 100644 --- a/style.css +++ b/style.css @@ -18,7 +18,7 @@ #score { font-size: 4vmin; text-align: center; - width: 100%; + width: 30%; } #highscores { text-align: center; @@ -37,18 +37,18 @@ button:focus { } #openSideBar { position: absolute; - top: 10px; - left: 10px; - z-index: 20000; + top: 3px; + left: 3px; + z-index: 3000; color:#000; cursor:hand; cursor:pointer; } #helpScreen { - height:100%; - width:100%; - z-index:10000; + height:30%; + width:30%; + z-index:3000; position:absolute; top:0%; left:0%; @@ -56,4 +56,37 @@ button:focus { color:#000; background-color:rgba(255,255,255,0.5); } +#overlay{ + transition: all 0.5s ease; + position:absolute; + height:20%; + width:40%; + left:50%; + top:50%; + margin-left:-20%; + margin-top:-5%; + z-index:3000; + color:#000; + text-align:center; +} +.faded{ + opacity:0; +} +.centeredHeader{ + font-size:72px; + text-align:center; + line-height:30px; +} +.centeredSubHeader{ + font-size:24; + text-align:center; +} +.blur{ + -webkit-filter: blur(3px); + -moz-filter: blur(3px); + -o-filter: blur(3px); + -ms-filter: blur(3px); + filter:blur(4px); + opacity:0.4; +}