diff --git a/index.css b/index.css index 622eaa5..91226ba 100644 --- a/index.css +++ b/index.css @@ -31,20 +31,6 @@ p { margin: 10px; } - -.message { - position: relative; - margin-bottom: -768px; - bottom: 768px; - - display: flex; - flex-direction: column; - justify-content: center; - align-items: center; - - background: rgba(0, 0, 0, 0.5); -} - .message span { display: block; text-align: center; @@ -59,7 +45,7 @@ p { padding: 10px; } -#canvas, .message { +#canvas { width: 768px; height: 768px; /*image-rendering: pixelated;*/ @@ -71,13 +57,8 @@ section#main { } @media (max-width: 1920px) { - #canvas, .message { + #canvas { width: min(512px, 90vw); height: min(512px, 90vw); } - - .message { - margin-bottom: min(512px, 90vw); - bottom: min(512px, 90vw); - } } \ No newline at end of file diff --git a/index.html b/index.html index 74cfe3a..a0992bb 100644 --- a/index.html +++ b/index.html @@ -11,10 +11,9 @@

UniButton

The left mouse is the only button. Click to launch... figure out the rest of the combos yourself.

By Onez, more games at Discord

+ href='https://discord.gg/EpsRZrHswBu'>Discord

-
placeholder diff --git a/js/index.js b/js/index.js index 796266a..daf7e9f 100644 --- a/js/index.js +++ b/js/index.js @@ -34,9 +34,7 @@ Game.prototype.main = function () { let { entities, player } = this; if (player.health <= 0) { - document.querySelector('.message').style.display = 'flex'; return; - } else { } for (let ent of entities) { @@ -98,6 +96,16 @@ Game.prototype.render = function () { } ctx.restore(); + + if (player.health <= 0) { + ctx.fillStyle = 'rgba(0,0,0,0.5)'; + ctx.fillRect(0,0,cs,cs); + ctx.fillStyle = 'rgb(255,255,255)'; + ctx.textAlign = "center"; + ctx.textBaseline = "middle"; + ctx.font = "bold 48px sans-serif"; + ctx.fillText('You died! Click to respawn',cs/2,cs/2); + } } Game.prototype.ui = function() { @@ -107,7 +115,11 @@ Game.prototype.ui = function() { Game.prototype.click = function () { let { player } = this; - player.bump(game); + if (player.health <= 0) { + game = new Game(); + } else { + player.bump(game); + } } var game = new Game();