diff options
author | Matt Kohls <mattkohls13@gmail.com> | 2019-12-09 23:27:55 -0500 |
---|---|---|
committer | Matt Kohls <mattkohls13@gmail.com> | 2019-12-09 23:27:55 -0500 |
commit | 421d3cee6dfad58fd48c2684da7494e730a16830 (patch) | |
tree | aa88ef6301ade2b1fbaf873e7a374a20e2947a38 /public | |
parent | c8a5d3a7597fc5b943a04e13aa8f3b01afdb3c48 (diff) | |
download | rogue.js-master.tar.gz rogue.js-master.tar.bz2 rogue.js-master.zip |
Diffstat (limited to 'public')
-rw-r--r-- | public/index.html | 2 | ||||
-rw-r--r-- | public/js/rogue.js | 25 |
2 files changed, 19 insertions, 8 deletions
diff --git a/public/index.html b/public/index.html index 47bcec0..5369ebd 100644 --- a/public/index.html +++ b/public/index.html @@ -16,7 +16,7 @@ <canvas id="gameboard" class="center" width="512" height="416"></canvas> <div class="center"> <table class="center"> - <tr><td><button id="joingame" type="button" title="Join Game">Join Game</button></td><td></td><td><button id="up">Up</button></td><td></td><td></td> + <tr><td><button id="joingame" type="button" title="Join Game">Join Game</button></td><td></td><td><button id="up">Up</button></td><td></td><td><button id="wait">Wait</button></td> </tr> <tr><td><button id="leavegame" type="button" title="Leave Game">Leave Game</button></td><td><button id="left">Left</button></td><td><button id="stairs">Stairs</button></td><td><button id="right">Right</button></td><td></td> </tr> diff --git a/public/js/rogue.js b/public/js/rogue.js index 3564103..bd14c21 100644 --- a/public/js/rogue.js +++ b/public/js/rogue.js @@ -142,6 +142,12 @@ function parseMessage(message) { } drawMap(); drawPlayerInfo(); + if(msg.msg === "You exit the dungeon, wielding THE STAFF!") { + drawMessageBox(scroll, "Congrats! You win!", 8, 19); + } + if(player.hp <= 0) { + drawMessageBox(tomb, "G a m e O v e r", 8, 19); + } } joinGame.onclick = function() { @@ -226,6 +232,15 @@ right.onclick = function() { websocket.send("{\"action\":\"move\", \"message\":\"d\"}"); } +wait.onclick = function() { + if (!websocket) { + showMessage('Connection error'); + return; + } + + websocket.send("{\"action\":\"wait\", \"message\":\" \"}"); +} + const canvas = document.getElementById('gameboard'); const context = canvas.getContext('2d'); const spritemap = new Image(320, 1264); @@ -397,13 +412,9 @@ function drawPlayerInfo() { renderText(player.staff.toString(), 31 - boxWidth + 5, 13); renderText(player.armor.toString(), 31 - boxWidth + 5, 14); renderText(player.potions.toString(), 31 - boxWidth + 5, 15); - - if(player.hp <= 0) { - drawGameOver(); - } } -function drawGameOver() { +function drawMessageBox(sprite, message, x, y) { for(var i = 0; i < 14; i++) { for(var j = 0; j < 5; j++) { drawSprite(nothing, 5 + i, 17 + j, false); @@ -419,8 +430,8 @@ function drawGameOver() { drawSprite(border[0], 19, 17, false); drawSprite(border[3], 5, 21, false); drawSprite(border[2], 19, 21, false); - drawSprite(tomb, 11, 13, false); - renderText("G a m e O v e r", 8, 19); + drawSprite(sprite, 11, 13, false); + renderText(message, x, y); if(websocket) { showMessage('Disconnecting from game'); |