aboutsummaryrefslogtreecommitdiffstats
path: root/public
diff options
context:
space:
mode:
authorMatt Kohls <mattkohls13@gmail.com>2019-12-05 01:49:58 -0500
committerMatt Kohls <mattkohls13@gmail.com>2019-12-05 01:49:58 -0500
commite4312e8008106eadd1b4d8a23630600f5952a8ca (patch)
treebdd3b87d69837737430edcb0b3a1fabe5963a092 /public
parent445013b6b675c6687af52d184a993c6567ed2975 (diff)
downloadrogue.js-e4312e8008106eadd1b4d8a23630600f5952a8ca.tar.gz
rogue.js-e4312e8008106eadd1b4d8a23630600f5952a8ca.tar.bz2
rogue.js-e4312e8008106eadd1b4d8a23630600f5952a8ca.zip
Players can run around and attack each other, client disconnects on
death
Diffstat (limited to 'public')
-rw-r--r--public/js/rogue.js36
1 files changed, 34 insertions, 2 deletions
diff --git a/public/js/rogue.js b/public/js/rogue.js
index 0b584a7..5a9896e 100644
--- a/public/js/rogue.js
+++ b/public/js/rogue.js
@@ -136,7 +136,7 @@ function parseMessage(message) {
var msg = JSON.parse(message);
map = msg.map;
player = new Player(msg.strength, msg.dexterity, msg.constitution, msg.intelligence, msg.wisdom, msg.level, msg.x, msg.y, msg.floor, msg.hp, msg.ac, msg.potions, msg.armor, msg.weapon, msg.staff);
- if(msg.msg != "") {
+ if(msg.msg != "" && msg.msg != "undefined") {
showMessage(msg.msg);
}
drawMap();
@@ -299,7 +299,7 @@ function drawMap() {
localX++;
}
- drawSprite(players[0], 10, 13, false);
+ drawSprite(players[0], 11, 13, false);
}
/**
@@ -356,6 +356,36 @@ 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() {
+ for(var i = 0; i < 14; i++) {
+ for(var j = 0; j < 5; j++) {
+ drawSprite(nothing, 5 + i, 17 + j, false);
+ if(i == 0) {
+ drawSprite(border[5], 5, 17 + j, false);
+ drawSprite(border[4], 19, 17 + j, false);
+ }
+ }
+ drawSprite(border[6], 5 + i, 17, false);
+ drawSprite(border[7], 5 + i, 21, false);
+ }
+ drawSprite(border[1], 5, 17, false);
+ 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);
+
+ if(websocket) {
+ showMessage('Disconnecting from game');
+ websocket.onerror = websocket.onopen = websocket.onclose = websocket.onmessage = null;
+ websocket.close();
+ }
}
/**
@@ -426,6 +456,8 @@ function renderText(message, x, y) {
sprite = indexSprite(upper, character - 65);
} else if(character >= 97 && character <= 122) {
sprite = indexSprite(lower, character - 97);
+ } else if(character == 45) {
+ sprite = indexSprite(symbol, 21);
}
// TODO: Add other symbols
}