aboutsummaryrefslogtreecommitdiffstats
path: root/public
diff options
context:
space:
mode:
authorMatt Kohls <mattkohls13@gmail.com>2019-12-09 20:57:21 -0500
committerMatt Kohls <mattkohls13@gmail.com>2019-12-09 20:57:21 -0500
commitc8a5d3a7597fc5b943a04e13aa8f3b01afdb3c48 (patch)
tree646d763c0972739f2f36eb42019bbd35ce4d955d /public
parenta5c786cc8a621ae70425a7795592ecfdfb1758ac (diff)
downloadrogue.js-c8a5d3a7597fc5b943a04e13aa8f3b01afdb3c48.tar.gz
rogue.js-c8a5d3a7597fc5b943a04e13aa8f3b01afdb3c48.tar.bz2
rogue.js-c8a5d3a7597fc5b943a04e13aa8f3b01afdb3c48.zip
Lots of improvements and bug fixes
Staff is now goal, and is given when trying to go down bottom stairs. Moving between floors now puts character on correct stairs. +'s and other symbols are now rendered on client. Mobs now have a type, and client will pick a proper sprite for them. Crashing on undefined action should be fixed.
Diffstat (limited to 'public')
-rw-r--r--public/index.html2
-rw-r--r--public/js/rogue.js59
-rw-r--r--public/styles/simple.css2
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>&copy; 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 {