Merge branch 'gh-pages' of https://github.com/teamsnowman/hextris into gh-pages

This commit is contained in:
lengstrom 2014-07-02 23:51:43 -04:00
commit a614f5aec7
5 changed files with 65 additions and 49 deletions

View file

@ -1,46 +1,3 @@
var prevGameState;
function showText(text){
var messages = {
'paused':"<div class='centeredHeader unselectable'>Paused</div><br><div class='unselectable centeredSubHeader'>Press p to resume</div>",
'start':"<div class='centeredHeader unselectable' style='line-height:80px;' >Press enter to start</div>",
'gameover':"<div class='centeredHeader unselectable'> Game Over: "+score+" pts</div><br><table class='tg' style='margin:0px auto'> <tr> <th class='tg-031e'>1.</th> <th class='tg-031e'>"+highscores[0]+"</th> </tr> <tr> <td class='tg-031e'>2.</td> <th class='tg-031e'>"+highscores[1]+"</th> </tr> <tr> <td class='tg-031e'>3.</td> <th class='tg-031e'>"+highscores[2]+"</th> </tr> </table><br><div class='unselectable centeredSubHeader'>Press enter to restart</div>",
};
var pt = document.getElementById("overlay");
pt.className = '';
pt.innerHTML = messages[text];
}
function hideText(text){
var pt = document.getElementById("overlay");
pt.className = 'faded';
pt.innerHTML = '';
}
function gameOverDisplay(){
var c = document.getElementById("canvas");
c.className = "blur";
showText('gameover');
}
function pause(x,o,message) {
message = 'paused';
var c = document.getElementById("canvas");
if (gameState == -1 ) {
hideText();
c.className = '';
setTimeout(function(){
gameState = prevGameState;
}, 300);
}
else if(gameState != -2 && gameState !== 0 && gameState !== 2) {
c.className = "blur";
showText(message);
prevGameState = gameState;
gameState = -1;
}
}
keypress.register_combo({
keys: "left",
on_keydown: function() {

View file

@ -395,7 +395,9 @@ window.onblur = function (e) {
}
};
function showHelp(){
pause(false,true);
if(gameState =1){
pause();
}
if(document.getElementById("helpScreen").style.display=="none" || document.getElementById("helpScreen").style.display === ""){
document.getElementById("helpScreen").style.display = "block";
}

View file

@ -32,9 +32,7 @@ function render() {
}
MainClock.draw();
if (gameState ==1 || gameState ==-1 || gameState === 0) {
drawScoreboard();
}
drawScoreboard();
for (i = 0; i < MainClock.texts.length; i++) {
var alive = MainClock.texts[i].draw();

View file

@ -51,18 +51,29 @@ function renderText(x, y, fontSize, color, text, font) {
}
scoreOpacity = 0;
var textOpacity=0;
function drawScoreboard() {
if (scoreOpacity < 1) {
scoreOpacity += 0.01;
textOpacity += 0.01;
}
ctx.globalAlpha = scoreOpacity;
ctx.globalAlpha = textOpacity;
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){
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 {
ctx.globalAlpha = scoreOpacity;
renderText(trueCanvas.width/2+ gdx, trueCanvas.height/2+ gdy, 50, "rgb(236, 240, 241)", score);
}
@ -115,3 +126,47 @@ function toggleClass(element, active) {
$(element).addClass(active);
}
}
var prevGameState;
function showText(text){
var messages = {
'paused':"<div class='centeredHeader unselectable'>Paused</div><br><div class='unselectable centeredSubHeader'>Press p to resume</div>",
'start':"<div class='centeredHeader unselectable' style='line-height:80px;' >Press enter to start</div>",
'gameover':"<div class='centeredHeader unselectable'> Game Over: "+score+" pts</div><br><table class='tg' style='margin:0px auto'> <tr> <th class='tg-031e'>1.</th> <th class='tg-031e'>"+highscores[0]+"</th> </tr> <tr> <td class='tg-031e'>2.</td> <th class='tg-031e'>"+highscores[1]+"</th> </tr> <tr> <td class='tg-031e'>3.</td> <th class='tg-031e'>"+highscores[2]+"</th> </tr> </table><br><div class='unselectable centeredSubHeader'>Press enter to restart</div>",
};
var pt = document.getElementById("overlay");
pt.className = 'unfaded';
pt.innerHTML = messages[text];
}
function hideText(text){
var pt = document.getElementById("overlay");
pt.className = 'faded';
pt.innerHTML = '';
}
function gameOverDisplay(){
var c = document.getElementById("canvas");
c.className = "blur";
showText('gameover');
}
function pause(x,o,message) {
message = 'paused';
var c = document.getElementById("canvas");
if (gameState == -1 ) {
hideText();
c.className = '';
setTimeout(function(){
gameState = prevGameState;
}, 300);
}
else if(gameState != -2 && gameState !== 0 && gameState !== 2) {
c.className = "blur";
showText(message);
prevGameState = gameState;
gameState = -1;
}
}

View file

@ -95,7 +95,7 @@ button:focus {
left:0%;
display:none;
color:#000;
background-color:rgba(255,255,255,0.5);
background-color:rgba(255,255,255,0.0);
}
#overlay {
@ -116,6 +116,10 @@ button:focus {
opacity:0;
}
.unfaded {
opacity:1;
}
.centeredHeader {
font-size:5em;
text-align:center;