diff --git a/js/main.js b/js/main.js index 581443d..64d5154 100644 --- a/js/main.js +++ b/js/main.js @@ -13,7 +13,7 @@ socket.on('getmap', function (map) { domMap.empty(); for(var w=0;w=map.length-1 || h>=map[w].length-1)) spClass = "water"; else if((map[w][h-1]=="0" && map[w][h]=="1" && map[w][h+1]=="2" && map[w-1][h+1]=="1") || (map[w-1][h-1]=="0" && map[w][h]=="1" && map[w+1][h]=="2" && map[w+1][h-1]=="1") || (map[w+1][h]=="2" && map[w][h]=="1" && map[w][h+1]=="2")) { diff --git a/s_map.js b/s_map.js index 5668eac..5bdaab7 100644 --- a/s_map.js +++ b/s_map.js @@ -17,7 +17,7 @@ module.exports = { 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"]; 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","4","4","0","0","0","0","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","4","0","0","0","0","0"]; map[i++] = ["0","0","0","0","0","0","0","0","0","0","0","4","0","0","0","0","0"]; map[i++] = ["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"]; @@ -39,21 +39,16 @@ module.exports = { } } - return map; + //return map; for(var w=0;w=width-1 || h>=height-1) { - map[w][h] = "0"; - } else { - map[w][h] = "0"; - p = 0.1; - if(rand(p)) - map[w][h] = "#"; - } + map[w][h] = "0"; + p = 0.1; + if(rand(p)) + map[w][h] = "#"; } } @@ -85,43 +80,46 @@ module.exports = { } } - for(var w=0;wwidth-5 || h>height-5) { - map[w][h] = "0"; //border water - } - } - } - - for(i=0;i<10;i++) { //fill water holes - for(var w=1;w= 5) - 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]=="#") { + 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]=="#") { + 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]=="#") { + map[w][h]="#"; + } + } } } } } + for(var w=0;wwidth-7 || h>height-7) { + map[w][h] = "0"; //border water + } + } + } + /* groundtypes g = ground w = water */ @@ -136,17 +134,17 @@ module.exports = { } } - // var g = [4,3,2]; - // for(var k=0;k=width-1 || h>=height-1) && (map[w-1][h]==i || map[w][h-1]==i || map[w][h+1]==i || map[w+1][h]==i || map[w+1][h+1]==i || map[w-1][h-1]==i || map[w+1][h-1]==i || map[w-1][h+1]==i)) { - // map[w][h] = (i-1)+""; //set ground - // } - // } - // } - // } + var g = [4,3,2]; + for(var k=0;k=width-1 || h>=height-1) && (map[w-1][h]==i || map[w][h-1]==i || map[w][h+1]==i || map[w+1][h]==i || map[w+1][h+1]==i || map[w-1][h-1]==i || map[w+1][h-1]==i || map[w-1][h+1]==i)) { + map[w][h] = (i-1)+""; //set ground + } + } + } + } return map;