module.exports = { generateMap: function(width, height) { var map = []; 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"]; 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","0","0","0","0","0","0","0"]; map[i++] = ["0","0","0","0","4","0","0","0","0","0","0","0","0","0","0","0","0"]; map[i++] = ["0","0","0","0","4","0","0","0","0","0","0","0","0","0","0","0","0"]; map[i++] = ["0","0","0","0","4","0","0","0","0","0","0","0","0","0","0","0","0"]; map[i++] = ["0","0","0","0","4","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","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","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"]; 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","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"]; var g = [6,5,4,3,2]; for(var k=0;k=width-1 || h>=height-1) { map[w][h] = "0"; } else { map[w][h] = "0"; p = 0.1; if(rand(p)) map[w][h] = "#"; } } } //preprocessing for(i=0;i<8;i++) { //expand all islands var orgMap = []; 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] = "#"; } } } } /* groundtypes g = ground w = water */ //Set ground type for(var w=0;w=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; } }; function rand(p) { if(p > Math.random()*100) return true; return false; }