add chest to the game

This commit is contained in:
cracker0dks 2019-05-18 15:32:28 +02:00
parent 1cd9762a3b
commit 7429b1ae6d
4 changed files with 270 additions and 238 deletions

View File

@ -18,7 +18,8 @@
.flower { .flower {
width: 32px; width: 32px;
height: 32px; height: 32px;
background: url(../img/objectlayer.png) 125px -29px;; background: url(../img/objectlayer.png) 125px -29px;
;
} }
.tree1 { .tree1 {
@ -167,6 +168,19 @@
background: url(../img/ground_tiles.png) -135px -17px; background: url(../img/ground_tiles.png) -135px -17px;
} }
.treasure-closed {
width: 34px;
height: 36px;
background: url(../img/chest.png) 95px -221px;
}
.treasure-open {
width: 34px;
height: 36px;
background: url(../img/chest.png) 55px -213px;
}
.water { .water {
background: url(../img/ground_tiles.png) 192px 254px; background: url(../img/ground_tiles.png) 192px 254px;
} }

BIN
img/chest.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.2 KiB

View File

@ -137,6 +137,20 @@ module.exports = {
} }
} }
var treasureSet = false;
while (!treasureSet) {
for (var w = 0; w < width; w++) { //fill forest
for (var h = 0; h < height; h++) {
if (map[w][h] == "6" && Math.random() < 0.00001 && !treasureSet) {
treasureSet = true;
utilMap[w][h] = "treasure-closed";
console.log(w, h, "treasure")
}
}
}
}
var g = [6, 5, 4, 3, 2]; var g = [6, 5, 4, 3, 2];
for (var k = 0; k < g.length; k++) { for (var k = 0; k < g.length; k++) {
var i = g[k] + ""; var i = g[k] + "";
@ -155,6 +169,10 @@ module.exports = {
} }
}; };
function rndBetween(start, end) {
return Math.floor(Math.random() * end) + start;
}
function rand(p) { function rand(p) {
if (p > Math.random() * 100) if (p > Math.random() * 100)
return true; return true;

View File

@ -11,8 +11,8 @@ app.use(express.static(__dirname + '/'));
var server = require('http').Server(app); var server = require('http').Server(app);
var io = require('socket.io')(server); var io = require('socket.io')(server);
var map = require("./s_map.js"); var map = require("./s_map.js");
var mapWidth = 500; var mapWidth = 100;
var mapHeight = 500; var mapHeight = 100;
var maxX = mapWidth * 32; var maxX = mapWidth * 32;
var maxY = mapHeight * 32; var maxY = mapHeight * 32;
var newmap = map.generateMap(mapWidth,mapHeight); var newmap = map.generateMap(mapWidth,mapHeight);