diff options
Diffstat (limited to 'public')
-rw-r--r-- | public/index.html | 2 | ||||
-rw-r--r-- | public/js/rogue.js | 59 | ||||
-rw-r--r-- | public/styles/simple.css | 2 |
3 files changed, 52 insertions, 11 deletions
diff --git a/public/index.html b/public/index.html index e8adc13..47bcec0 100644 --- a/public/index.html +++ b/public/index.html @@ -12,6 +12,7 @@ <div class="center"> <h1>rogue.js</h1> </div> + <pre id="messages" style="height: 100px; overflow: scroll"></pre> <canvas id="gameboard" class="center" width="512" height="416"></canvas> <div class="center"> <table class="center"> @@ -23,7 +24,6 @@ </tr> </table> </div> - <pre id="messages" style="height: 400px; overflow: scroll"></pre> <footer><p>© Matt Kohls, 2019</footer> <script src="js/rogue.js"></script> </body> diff --git a/public/js/rogue.js b/public/js/rogue.js index d627c18..3564103 100644 --- a/public/js/rogue.js +++ b/public/js/rogue.js @@ -242,20 +242,36 @@ function drawInitialBoard() { drawSprite(nothing, i, j, false); } } - for(var i = 5; i < 30; i++) { - for(var j = 2; j < 10; j++) { - drawSprite(dirt, i, j, false); - } - } for(var i = 0; i < 32; i++) { drawSprite(wall[0], i, 0, false); - drawSprite(wall[1], i, 25, false); + drawSprite(wall[0], i, 25, false); } for(var j = 0; j < 26; j++) { - drawSprite(wall[2], 0, j, false); - drawSprite(wall[2], 31, j, false); + drawSprite(wall[0], 0, j, false); } + drawSprite(players[0], 4, 7, false); + renderText("This is you", 6, 7); + drawSprite(players[1], 4, 8, false); + renderText("These are other players", 6, 8); + drawSprite(zombie, 4, 9, false); + renderText("Watch out for monsters", 6, 9); + + drawSprite(stairsup, 4, 11, false); + drawSprite(stairsdown, 4, 12, false); + renderText("Stairs allow you to move", 6, 11); + renderText("between floors", 6, 12); + + drawSprite(potion, 4, 14, false); + renderText("Using a potion heals you", 6, 14); + drawSprite(sword, 4, 15, false); + renderText("Moving into someone attacks", 6, 15); + renderText("them", 6, 16); + + drawSprite(staff, 4, 18, false); + renderText("Find the staff and return", 6, 18); + renderText("to the surface", 6, 19); + drawPlayerInfo(); } @@ -305,7 +321,22 @@ function drawMap() { 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); + var sprite; + switch(mobs[i].type) { + case "player": + sprite = players[1]; + break; + case "zombie": + sprite = zombie; + break; + case "slime": + sprite = slime; + break; + default: + sprite = rat; + break; + } + drawSprite(sprite, 11 + mobx, 13 + moby, false); } } @@ -468,6 +499,16 @@ function renderText(message, x, y) { sprite = indexSprite(lower, character - 97); } else if(character == 45) { sprite = indexSprite(symbol, 21); + } else if(character == 43) { + sprite = indexSprite(symbol, 20); + } else if(character == 46) { + sprite = indexSprite(symbol, 5); + } else if(character == 44) { + sprite = indexSprite(symbol, 6); + } else if(character == 33) { + sprite = indexSprite(symbol, 7); + } else if(character == 63) { + sprite = indexSprite(symbol, 8); } // TODO: Add other symbols } diff --git a/public/styles/simple.css b/public/styles/simple.css index 490e115..f342e78 100644 --- a/public/styles/simple.css +++ b/public/styles/simple.css @@ -48,7 +48,7 @@ p { } table, th, td { - border: 1px solid black; + border: 0px solid black; } th, td { |