diff options
author | Matt Kohls <mattkohls13@gmail.com> | 2019-12-05 14:32:22 -0500 |
---|---|---|
committer | Matt Kohls <mattkohls13@gmail.com> | 2019-12-05 14:32:22 -0500 |
commit | a5c786cc8a621ae70425a7795592ecfdfb1758ac (patch) | |
tree | 4b6b7ad7a7586d799e0e0d009ed00b33e885c799 /public/js | |
parent | e4312e8008106eadd1b4d8a23630600f5952a8ca (diff) | |
download | rogue.js-a5c786cc8a621ae70425a7795592ecfdfb1758ac.tar.gz rogue.js-a5c786cc8a621ae70425a7795592ecfdfb1758ac.tar.bz2 rogue.js-a5c786cc8a621ae70425a7795592ecfdfb1758ac.zip |
Client now sent list of mobs to draw
Currently only draws them as the alt player sprite and doesn't show them
as bones if they died this turn
Diffstat (limited to 'public/js')
-rw-r--r-- | public/js/rogue.js | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/public/js/rogue.js b/public/js/rogue.js index 5a9896e..d627c18 100644 --- a/public/js/rogue.js +++ b/public/js/rogue.js @@ -135,6 +135,7 @@ function showMessage(message) { function parseMessage(message) { var msg = JSON.parse(message); map = msg.map; + mobs = msg.mobs; 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 != "" && msg.msg != "undefined") { showMessage(msg.msg); @@ -232,6 +233,7 @@ spritemap.onload = drawInitialBoard; spritemap.src = 'scroll-o-sprites-edited.png'; var gamemap; +var mobs; var player = new Player(10, 10, 10, 10, 10, 1, 0, 0, 1, 100, 15, 0, "none", "none", "none"); function drawInitialBoard() { @@ -299,6 +301,14 @@ function drawMap() { localX++; } + for(var i = 0; i < mobs.length; i++) { + if(mobs[i].floor == player.floor) { + var mobx = mobs[i].x - player.x; + var moby = mobs[i].y - player.y; + drawSprite(players[1], 11 + mobx, 13 + moby, false); + } + } + drawSprite(players[0], 11, 13, false); } |