add flowers

This commit is contained in:
rofl256 2016-10-20 22:33:08 +02:00
parent 9c539f7758
commit 5550c98622
5 changed files with 44 additions and 17 deletions

View File

@ -4,6 +4,16 @@
position: absolute;
}
.spriteUtils{
position: absolute;
}
.flower{
width: 32px;
height: 32px;
background: url(../img/objectlayer.png) 125px -29px;;
}
.water {
background: url(../img/ground_tiles.png) 192px 254px;
}

BIN
img/Extra_Unfinished4.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 42 KiB

BIN
img/objectlayer.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 32 KiB

View File

@ -6,8 +6,10 @@ socket.on('connect', function () {
socket.emit("getmap", 100, 100);
});
socket.on('getmap', function (map) {
console.log(map);
socket.on('getmap', function (conent) {
var map = conent["map"];
var utilMap = conent["utilMap"];
//console.log(map);
var domMap = $("#map");
domMap.empty();
@ -164,7 +166,16 @@ socket.on('getmap', function (map) {
else if(map[w][h-1]=="5" && map[w][h]=="5" && map[w-1][h]=="5")
spClass = "rightLeftB_5";
domMap.append('<img style="top:'+(w*32)+'px; left:'+(h*32)+'px" src="./img/plain.png" i="'+map[w][h]+'" class="sprite '+spClass+'">');
domMap.append('<img style="top:'+(w*32)+'px; left:'+(h*32)+'px; z-index:1;" src="./img/plain.png" i="'+map[w][h]+'" class="sprite '+spClass+'">');
}
}
for(var w=0;w<map.length;w++) {
for(var h=0;h<map[w].length;h++) {
if(utilMap[w][h]!="") {
console.log("FLOWER");
domMap.append('<img style="top:'+(w*32)+'px; left:'+(h*32)+'px; z-index:2;" src="./img/plain.png" i="'+utilMap[w][h]+'" class="spriteUtils '+utilMap[w][h]+'">');
}
}
}
});

View File

@ -1,6 +1,7 @@
module.exports = {
generateMap: function(width, height) {
var map = [];
var utilMap = [];
var i = 0;
map[i++] = ["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"];
map[i++] = ["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"];
@ -44,10 +45,11 @@ module.exports = {
for(var w=0;w<width;w++) {
map[w] = [];
utilMap[w] = [];
for(var h=0;h<height;h++) {
map[w][h] = "0";
p = 0.1;
if(rand(p))
utilMap[w][h] = "";
if(Math.random()<0.0006)
map[w][h] = "#";
}
}
@ -80,30 +82,30 @@ module.exports = {
}
}
for(var i=0;i<10;i++) {
for(var i=0;i<2;i++) {
for(var w=7;w<width-7;w++) {
for(var h=7;h<height-7;h++) {
if(map[w][h]=="0") {
if(map[w][h-1]=="#" || map[w][h-2]=="#" || map[w][h-3]=="#" || map[w][h-4]=="#") {
if(map[w][h+1]=="#" || map[w][h+2]=="#" || map[w][h+3]=="#" || map[w][h+4]=="#") {
if(map[w][h-1]=="#" || map[w][h-2]=="#" || map[w][h-3]=="#" || map[w][h-4]=="#" || map[w][h-5]=="#" || map[w][h-6]=="#") {
if(map[w][h+1]=="#" || map[w][h+2]=="#" || map[w][h+3]=="#" || map[w][h+4]=="#" || map[w][h+5]=="#" || map[w][h+6]=="#") {
map[w][h]="#";
}
}
if(map[w-1][h]=="#" || map[w-2][h]=="#" || map[w-3][h]=="#" || map[w-4][h]=="#") {
if(map[w+1][h]=="#" || map[w+2][h]=="#" || map[w+3][h]=="#" || map[w+4][h]=="#") {
if(map[w-1][h]=="#" || map[w-2][h]=="#" || map[w-3][h]=="#" || map[w-4][h]=="#" || map[w-5][h]=="#" || map[w-6][h]=="#") {
if(map[w+1][h]=="#" || map[w+2][h]=="#" || map[w+3][h]=="#" || map[w+4][h]=="#" || map[w+5][h]=="#" || map[w+6][h]=="#") {
map[w][h]="#";
}
}
if(map[w-1][h-1]=="#" || map[w-2][h-2]=="#" || map[w-3][h-3]=="#" || map[w-4][h-4]=="#") {
if(map[w+1][h+1]=="#" || map[w+2][h+2]=="#" || map[w+3][h+3]=="#" || map[w+4][h+4]=="#") {
if(map[w-1][h-1]=="#" || map[w-2][h-2]=="#" || map[w-3][h-3]=="#" || map[w-4][h-4]=="#" || map[w-5][h-5]=="#" || map[w-6][h-6]=="#") {
if(map[w+1][h+1]=="#" || map[w+2][h+2]=="#" || map[w+3][h+3]=="#" || map[w+4][h+4]=="#" || map[w+5][h+5]=="#" || map[w+6][h+6]=="#") {
map[w][h]="#";
}
}
if(map[w+1][h-1]=="#" || map[w+2][h-2]=="#" || map[w+3][h-3]=="#" || map[w+4][h-4]=="#") {
if(map[w-1][h+1]=="#" || map[w-2][h+2]=="#" || map[w-3][h+3]=="#" || map[w-4][h+4]=="#") {
if(map[w+1][h-1]=="#" || map[w+2][h-2]=="#" || map[w+3][h-3]=="#" || map[w+4][h-4]=="#" || map[w+5][h-5]=="#" || map[w+6][h-6]=="#") {
if(map[w-1][h+1]=="#" || map[w-2][h+2]=="#" || map[w-3][h+3]=="#" || map[w-4][h+4]=="#" || map[w-5][h+5]=="#" || map[w-6][h+6]=="#") {
map[w][h]="#";
}
}
@ -129,12 +131,16 @@ module.exports = {
for(var w=0;w<width;w++) {
for(var h=0;h<height;h++) {
if(map[w][h] == "#") {
map[w][h] = "4"; //set ground
map[w][h] = "6"; //set ground
if(Math.random()<0.011) {
utilMap[w][h] = "flower";
}
}
}
}
var g = [4,3,2];
var g = [6,5,4,3,2];
for(var k=0;k<g.length;k++) {
var i = g[k]+"";
for(var w=0;w<width;w++) {
@ -147,7 +153,7 @@ module.exports = {
}
return map;
return {"map":map, "utilMap":utilMap};
}
};