add chest to the game
This commit is contained in:
parent
1cd9762a3b
commit
7429b1ae6d
38
css/main.css
38
css/main.css
@ -5,30 +5,31 @@
|
||||
}
|
||||
|
||||
.animate {
|
||||
background-position:left bottom !important;
|
||||
background-position: left bottom !important;
|
||||
}
|
||||
|
||||
.spriteUtils{
|
||||
.spriteUtils {
|
||||
position: absolute;
|
||||
-webkit-transform: scale(0.7);
|
||||
transform: scale(0.7);
|
||||
transform-origin: 0;
|
||||
}
|
||||
|
||||
.flower{
|
||||
.flower {
|
||||
width: 32px;
|
||||
height: 32px;
|
||||
background: url(../img/objectlayer.png) 125px -29px;;
|
||||
background: url(../img/objectlayer.png) 125px -29px;
|
||||
;
|
||||
}
|
||||
|
||||
.tree1{
|
||||
.tree1 {
|
||||
width: 60px;
|
||||
height: 60px;
|
||||
z-index: 110 !important;
|
||||
background: url(../img/objectlayer.png) 315px -70px;
|
||||
}
|
||||
|
||||
.stone1{
|
||||
.stone1 {
|
||||
width: 32px;
|
||||
height: 35px;
|
||||
background: url(../img/objectlayer.png) 158px -65px;
|
||||
@ -48,7 +49,7 @@
|
||||
top: -13px;
|
||||
left: -13px;
|
||||
background: url(../img/guy_sprite.png) 0px 0px;
|
||||
-webkit-transform: scale(0.7);
|
||||
-webkit-transform: scale(0.7);
|
||||
transform: scale(0.7);
|
||||
transform-origin: 0;
|
||||
}
|
||||
@ -150,23 +151,36 @@
|
||||
}
|
||||
|
||||
#main {
|
||||
-webkit-transform: scale(1.5);
|
||||
transform: scale(2);
|
||||
transform-origin: 0;
|
||||
-webkit-transform: scale(1.5);
|
||||
transform: scale(2);
|
||||
transform-origin: 0;
|
||||
}
|
||||
|
||||
.fass{
|
||||
.fass {
|
||||
width: 32px;
|
||||
height: 43px;
|
||||
background: url(../img/objectlayer.png) 157px -18px;
|
||||
}
|
||||
|
||||
.forest{
|
||||
.forest {
|
||||
width: 46px;
|
||||
height: 46px;
|
||||
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 {
|
||||
background: url(../img/ground_tiles.png) 192px 254px;
|
||||
}
|
||||
|
BIN
img/chest.png
Normal file
BIN
img/chest.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 6.2 KiB |
464
s_map.js
464
s_map.js
@ -1,187 +1,205 @@
|
||||
module.exports = {
|
||||
generateMap: function(width, height) {
|
||||
var map = [];
|
||||
var utilMap = [];
|
||||
generateMap: function (width, height) {
|
||||
var map = [];
|
||||
var utilMap = [];
|
||||
|
||||
var g = [6,5,4,3,2];
|
||||
for(var k=0;k<g.length;k++) {
|
||||
var i = g[k]+"";
|
||||
for(var w=1;w<map.length-1;w++) {
|
||||
for(var h=1;h<map[w].length-1;h++) {
|
||||
if(map[w][h] == "0" && (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;
|
||||
|
||||
|
||||
for(var w=0;w<width;w++) {
|
||||
map[w] = [];
|
||||
utilMap[w] = [];
|
||||
for(var h=0;h<height;h++) {
|
||||
map[w][h] = "0";
|
||||
utilMap[w][h] = "";
|
||||
if(Math.random()<0.0009)
|
||||
map[w][h] = "#";
|
||||
}
|
||||
}
|
||||
|
||||
//preprocessing
|
||||
|
||||
for(i=0;i<8;i++) { //expand all islands
|
||||
var orgMap = [];
|
||||
for(var w=0;w<width;w++) {
|
||||
orgMap[w] = [];
|
||||
for(var h=0;h<height;h++) {
|
||||
orgMap[w][h] = map[w][h];
|
||||
}
|
||||
var g = [6, 5, 4, 3, 2];
|
||||
for (var k = 0; k < g.length; k++) {
|
||||
var i = g[k] + "";
|
||||
for (var w = 1; w < map.length - 1; w++) {
|
||||
for (var h = 1; h < map[w].length - 1; h++) {
|
||||
if (map[w][h] == "0" && (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 exP = 80;
|
||||
for(var w=1;w<width-1;w++) {
|
||||
for(var h=1;h<height-1;h++) {
|
||||
if(orgMap[w][h]=="#") {
|
||||
if(rand(exP)) map[w-1][h]="#"
|
||||
if(rand(exP)) map[w+1][h]="#"
|
||||
if(rand(exP)) map[w][h-1]="#"
|
||||
if(rand(exP)) map[w][h+1]="#"
|
||||
if(rand(exP)) map[w-1][h-1]="#"
|
||||
if(rand(exP)) map[w-1][h+1]="#"
|
||||
if(rand(exP)) map[w+1][h-1]="#"
|
||||
if(rand(exP)) map[w+1][h+1]="#"
|
||||
}
|
||||
}
|
||||
}
|
||||
//return map;
|
||||
|
||||
|
||||
for (var w = 0; w < width; w++) {
|
||||
map[w] = [];
|
||||
utilMap[w] = [];
|
||||
for (var h = 0; h < height; h++) {
|
||||
map[w][h] = "0";
|
||||
utilMap[w][h] = "";
|
||||
if (Math.random() < 0.0009)
|
||||
map[w][h] = "#";
|
||||
}
|
||||
}
|
||||
|
||||
//preprocessing
|
||||
|
||||
for (i = 0; i < 8; i++) { //expand all islands
|
||||
var orgMap = [];
|
||||
for (var w = 0; w < width; w++) {
|
||||
orgMap[w] = [];
|
||||
for (var h = 0; h < height; h++) {
|
||||
orgMap[w][h] = map[w][h];
|
||||
}
|
||||
}
|
||||
|
||||
var exP = 80;
|
||||
for (var w = 1; w < width - 1; w++) {
|
||||
for (var h = 1; h < height - 1; h++) {
|
||||
if (orgMap[w][h] == "#") {
|
||||
if (rand(exP)) map[w - 1][h] = "#"
|
||||
if (rand(exP)) map[w + 1][h] = "#"
|
||||
if (rand(exP)) map[w][h - 1] = "#"
|
||||
if (rand(exP)) map[w][h + 1] = "#"
|
||||
if (rand(exP)) map[w - 1][h - 1] = "#"
|
||||
if (rand(exP)) map[w - 1][h + 1] = "#"
|
||||
if (rand(exP)) map[w + 1][h - 1] = "#"
|
||||
if (rand(exP)) map[w + 1][h + 1] = "#"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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] == "#" || 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] == "#" || 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] == "#" || 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] == "#" || 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] = "#";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (var w = 0; w < width; w++) {
|
||||
for (var h = 0; h < height; h++) {
|
||||
if (h <= 7 || w <= 7 || w > width - 7 || h > height - 7) {
|
||||
map[w][h] = "0"; //border water
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* groundtypes
|
||||
g = ground w = water
|
||||
*/
|
||||
//
|
||||
|
||||
//Set ground type
|
||||
for (var w = 0; w < width; w++) {
|
||||
for (var h = 0; h < height; h++) {
|
||||
if (map[w][h] == "#") { //is ground
|
||||
map[w][h] = "6"; //set ground
|
||||
|
||||
if (Math.random() < 0.011) {
|
||||
utilMap[w][h] = "forest";
|
||||
} else if (utilMap[w - 1][h] == "forest" || utilMap[w][h - 1] == "forest" || utilMap[w - 1][h - 1] == "forest") {
|
||||
if (Math.random() < 0.8) {
|
||||
utilMap[w][h] = "forest";
|
||||
}
|
||||
} else if (Math.random() < 0.011) {
|
||||
utilMap[w][h] = "flower";
|
||||
} else if (Math.random() < 0.011) {
|
||||
utilMap[w][h] = "tree1";
|
||||
} else if (Math.random() < 0.011) {
|
||||
utilMap[w][h] = "stone1";
|
||||
} else if (Math.random() < 0.011) {
|
||||
utilMap[w][h] = "fass";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (var w = 0; w < width; w++) { //fill forest
|
||||
for (var h = 0; h < height; h++) {
|
||||
if (map[w][h] == "6") {
|
||||
if ((utilMap[w - 1][h] == "forest" && utilMap[w + 1][h] == "forest") || (utilMap[w][h - 1] == "forest" && utilMap[w][h + 1] == "forest")) {
|
||||
utilMap[w][h] = "forest";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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];
|
||||
for (var k = 0; k < g.length; k++) {
|
||||
var i = g[k] + "";
|
||||
for (var w = 0; w < width; w++) {
|
||||
for (var h = 0; h < height; h++) {
|
||||
if (map[w][h] == "0" && !(w <= 0 || h <= 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
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var cssMap = addCssClass(map);
|
||||
|
||||
return { "map": map, "cssMap": cssMap, "utilMap": utilMap };
|
||||
}
|
||||
|
||||
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]=="#" || 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]=="#" || 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]=="#" || 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]=="#" || 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]="#";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for(var w=0;w<width;w++) {
|
||||
for(var h=0;h<height;h++) {
|
||||
if(h<=7 || w<=7 || w>width-7 || h>height-7) {
|
||||
map[w][h] = "0"; //border water
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* groundtypes
|
||||
g = ground w = water
|
||||
*/
|
||||
//
|
||||
|
||||
//Set ground type
|
||||
for(var w=0;w<width;w++) {
|
||||
for(var h=0;h<height;h++) {
|
||||
if(map[w][h] == "#") { //is ground
|
||||
map[w][h] = "6"; //set ground
|
||||
|
||||
if(Math.random()<0.011) {
|
||||
utilMap[w][h] = "forest";
|
||||
} else if(utilMap[w-1][h]=="forest" || utilMap[w][h-1]=="forest" || utilMap[w-1][h-1]=="forest") {
|
||||
if(Math.random()<0.8) {
|
||||
utilMap[w][h] = "forest";
|
||||
}
|
||||
}else if(Math.random()<0.011) {
|
||||
utilMap[w][h] = "flower";
|
||||
} else if(Math.random()<0.011) {
|
||||
utilMap[w][h] = "tree1";
|
||||
} else if(Math.random()<0.011) {
|
||||
utilMap[w][h] = "stone1";
|
||||
} else if(Math.random()<0.011) {
|
||||
utilMap[w][h] = "fass";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for(var w=0;w<width;w++) { //fill forest
|
||||
for(var h=0;h<height;h++) {
|
||||
if(map[w][h] == "6") {
|
||||
if((utilMap[w-1][h]=="forest" && utilMap[w+1][h]=="forest") || (utilMap[w][h-1]=="forest" && utilMap[w][h+1]=="forest")) {
|
||||
utilMap[w][h] = "forest";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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++) {
|
||||
for(var h=0;h<height;h++) {
|
||||
if(map[w][h] == "0" && !(w<=0 || h<=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
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var cssMap = addCssClass(map);
|
||||
|
||||
return {"map": map, "cssMap":cssMap, "utilMap":utilMap};
|
||||
}
|
||||
};
|
||||
|
||||
function rndBetween(start, end) {
|
||||
return Math.floor(Math.random() * end) + start;
|
||||
}
|
||||
|
||||
function rand(p) {
|
||||
if(p > Math.random()*100)
|
||||
if (p > Math.random() * 100)
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
function addCssClass(map) {
|
||||
var cssMap = [];
|
||||
for(var w=0;w<map.length;w++) {
|
||||
cssMap[w] = [];
|
||||
for(var h=0;h<map[w].length;h++) {
|
||||
var cssMap = [];
|
||||
for (var w = 0; w < map.length; w++) {
|
||||
cssMap[w] = [];
|
||||
for (var h = 0; h < map[w].length; h++) {
|
||||
var spClass = "ground_";
|
||||
if(map[w][h]=="0" || (w<=0 || h<=0 || w>=map.length-1 || h>=map[w].length-1)) {
|
||||
if(Math.random()<0.001)
|
||||
if (map[w][h] == "0" || (w <= 0 || h <= 0 || w >= map.length - 1 || h >= map[w].length - 1)) {
|
||||
if (Math.random() < 0.001)
|
||||
spClass = "water_1";
|
||||
else if(Math.random()<0.001)
|
||||
else if (Math.random() < 0.001)
|
||||
spClass = "water_2";
|
||||
else
|
||||
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")) {
|
||||
if(map[w][h+1]=="2" && map[w+1][h]=="2") {
|
||||
if(map[w-1][h+1]=="1" && map[w+1][h-1]=="2")
|
||||
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")) {
|
||||
if (map[w][h + 1] == "2" && map[w + 1][h] == "2") {
|
||||
if (map[w - 1][h + 1] == "1" && map[w + 1][h - 1] == "2")
|
||||
spClass = "topDown_1";
|
||||
else if(map[w+1][h-1]=="1" && map[w-1][h+1]=="2")
|
||||
else if (map[w + 1][h - 1] == "1" && map[w - 1][h + 1] == "2")
|
||||
spClass = "leftRight_1";
|
||||
else if(map[w+1][h-1]=="2" && map[w-1][h+1]=="2")
|
||||
else if (map[w + 1][h - 1] == "2" && map[w - 1][h + 1] == "2")
|
||||
spClass = "leftRightTT_1";
|
||||
else
|
||||
spClass = "leftRightT_1";
|
||||
@ -189,13 +207,13 @@ function addCssClass(map) {
|
||||
else
|
||||
spClass = "leftRightT_1";
|
||||
}
|
||||
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]=="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")) {
|
||||
if(map[w][h-1]=="2" && map[w+1][h]=="2") {
|
||||
if(map[w-1][h-1]=="1" && map[w+1][h+1]=="2")
|
||||
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] == "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")) {
|
||||
if (map[w][h - 1] == "2" && map[w + 1][h] == "2") {
|
||||
if (map[w - 1][h - 1] == "1" && map[w + 1][h + 1] == "2")
|
||||
spClass = "topDown_1";
|
||||
else if(map[w+1][h+1]=="1" && map[w-1][h-1]=="2")
|
||||
else if (map[w + 1][h + 1] == "1" && map[w - 1][h - 1] == "2")
|
||||
spClass = "rightLeft_1";
|
||||
else if(map[w-1][h-1]=="2" && map[w+1][h-1]=="2")
|
||||
else if (map[w - 1][h - 1] == "2" && map[w + 1][h - 1] == "2")
|
||||
spClass = "rightLeftTT_1";
|
||||
else
|
||||
spClass = "rightLeftT_1";
|
||||
@ -203,13 +221,13 @@ function addCssClass(map) {
|
||||
else
|
||||
spClass = "rightLeftT_1";
|
||||
}
|
||||
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]=="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")) {
|
||||
if(map[w][h+1]=="2" && map[w-1][h]=="2") {
|
||||
if(map[w+1][h+1]=="1" && map[w-1][h-1]=="2")
|
||||
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] == "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")) {
|
||||
if (map[w][h + 1] == "2" && map[w - 1][h] == "2") {
|
||||
if (map[w + 1][h + 1] == "1" && map[w - 1][h - 1] == "2")
|
||||
spClass = "downTop_1";
|
||||
else if(map[w-1][h-1]=="1" && map[w+1][h+1]=="2")
|
||||
else if (map[w - 1][h - 1] == "1" && map[w + 1][h + 1] == "2")
|
||||
spClass = "leftRight_1";
|
||||
else if(map[w-1][h-1]=="2" && map[w+1][h+1]=="2")
|
||||
else if (map[w - 1][h - 1] == "2" && map[w + 1][h + 1] == "2")
|
||||
spClass = "rightLeftBB_1";
|
||||
else
|
||||
spClass = "rightLeftB_1";
|
||||
@ -217,13 +235,13 @@ function addCssClass(map) {
|
||||
else
|
||||
spClass = "rightLeftB_1";
|
||||
}
|
||||
else if((map[w+1][h]=="0" && map[w][h]=="1" && map[w-1][h]=="2" && map[w-1][h+1]=="1") || (map[w][h+1]=="0" && map[w][h]=="1" && map[w][h-1]=="2" && map[w+1][h-1]=="1") || (map[w-1][h]=="2" && map[w][h]=="1" && map[w][h-1]=="2")) {
|
||||
if(map[w][h-1]=="2" && map[w-1][h]=="2") {
|
||||
if(map[w+1][h-1]=="1" && map[w-1][h+1]=="2")
|
||||
else if ((map[w + 1][h] == "0" && map[w][h] == "1" && map[w - 1][h] == "2" && map[w - 1][h + 1] == "1") || (map[w][h + 1] == "0" && map[w][h] == "1" && map[w][h - 1] == "2" && map[w + 1][h - 1] == "1") || (map[w - 1][h] == "2" && map[w][h] == "1" && map[w][h - 1] == "2")) {
|
||||
if (map[w][h - 1] == "2" && map[w - 1][h] == "2") {
|
||||
if (map[w + 1][h - 1] == "1" && map[w - 1][h + 1] == "2")
|
||||
spClass = "downTop_1";
|
||||
else if(map[w-1][h+1]=="1" && map[w+1][h-1]=="2")
|
||||
else if (map[w - 1][h + 1] == "1" && map[w + 1][h - 1] == "2")
|
||||
spClass = "rightLeft_1";
|
||||
else if(map[w-1][h+1]=="2" && map[w-1][h+1]=="2")
|
||||
else if (map[w - 1][h + 1] == "2" && map[w - 1][h + 1] == "2")
|
||||
spClass = "leftRightBB_1";
|
||||
else
|
||||
spClass = "leftRightB_1";
|
||||
@ -232,99 +250,99 @@ function addCssClass(map) {
|
||||
spClass = "leftRightB_1";
|
||||
}
|
||||
|
||||
else if(map[w][h-1]=="3" && map[w][h]=="2" && map[w-1][h]=="3")
|
||||
else if (map[w][h - 1] == "3" && map[w][h] == "2" && map[w - 1][h] == "3")
|
||||
spClass = "rightLeftBU_2";
|
||||
else if(map[w][h-1]=="4" && map[w][h]=="3" && map[w-1][h]=="4")
|
||||
else if (map[w][h - 1] == "4" && map[w][h] == "3" && map[w - 1][h] == "4")
|
||||
spClass = "rightLeftBU_3";
|
||||
else if(map[w][h-1]=="6" && map[w][h]=="5" && map[w-1][h]=="6")
|
||||
else if (map[w][h - 1] == "6" && map[w][h] == "5" && map[w - 1][h] == "6")
|
||||
spClass = "rightLeftBU_5";
|
||||
|
||||
else if(map[w][h+1]=="3" && map[w][h]=="2" && map[w-1][h]=="3")
|
||||
else if (map[w][h + 1] == "3" && map[w][h] == "2" && map[w - 1][h] == "3")
|
||||
spClass = "leftRightBU_2";
|
||||
else if(map[w][h+1]=="4" && map[w][h]=="3" && map[w-1][h]=="4")
|
||||
else if (map[w][h + 1] == "4" && map[w][h] == "3" && map[w - 1][h] == "4")
|
||||
spClass = "leftRightBU_3";
|
||||
else if(map[w][h+1]=="6" && map[w][h]=="5" && map[w-1][h]=="6")
|
||||
else if (map[w][h + 1] == "6" && map[w][h] == "5" && map[w - 1][h] == "6")
|
||||
spClass = "leftRightBU_5";
|
||||
|
||||
else if(map[w][h+1]=="3" && map[w][h]=="2" && map[w+1][h]=="3")
|
||||
else if (map[w][h + 1] == "3" && map[w][h] == "2" && map[w + 1][h] == "3")
|
||||
spClass = "rightLeftTU_2";
|
||||
else if(map[w][h+1]=="4" && map[w][h]=="3" && map[w+1][h]=="4")
|
||||
else if (map[w][h + 1] == "4" && map[w][h] == "3" && map[w + 1][h] == "4")
|
||||
spClass = "rightLeftTU_3";
|
||||
else if(map[w][h+1]=="6" && map[w][h]=="5" && map[w+1][h]=="6")
|
||||
else if (map[w][h + 1] == "6" && map[w][h] == "5" && map[w + 1][h] == "6")
|
||||
spClass = "rightLeftTU_5";
|
||||
|
||||
else if(map[w][h-1]=="3" && map[w][h]=="2" && map[w+1][h]=="3")
|
||||
else if (map[w][h - 1] == "3" && map[w][h] == "2" && map[w + 1][h] == "3")
|
||||
spClass = "leftRightTU_2";
|
||||
else if(map[w][h-1]=="4" && map[w][h]=="3" && map[w+1][h]=="4")
|
||||
else if (map[w][h - 1] == "4" && map[w][h] == "3" && map[w + 1][h] == "4")
|
||||
spClass = "leftRightTU_3";
|
||||
else if(map[w][h-1]=="6" && map[w][h]=="5" && map[w+1][h]=="6")
|
||||
else if (map[w][h - 1] == "6" && map[w][h] == "5" && map[w + 1][h] == "6")
|
||||
spClass = "leftRightTU_5";
|
||||
|
||||
else if(map[w][h-1]=="0" && map[w][h]=="1" && map[w][h+1]=="2")
|
||||
else if (map[w][h - 1] == "0" && map[w][h] == "1" && map[w][h + 1] == "2")
|
||||
spClass = "leftRight_1";
|
||||
else if(map[w][h-1]=="1" && map[w][h]=="2" && map[w][h+1]=="3")
|
||||
else if (map[w][h - 1] == "1" && map[w][h] == "2" && map[w][h + 1] == "3")
|
||||
spClass = "leftRight_2";
|
||||
else if(map[w][h-1]=="2" && map[w][h]=="3" && map[w][h+1]=="4")
|
||||
else if (map[w][h - 1] == "2" && map[w][h] == "3" && map[w][h + 1] == "4")
|
||||
spClass = "leftRight_3";
|
||||
else if(map[w][h]=="4")
|
||||
else if (map[w][h] == "4")
|
||||
spClass = "ground";
|
||||
else if(map[w][h-1]=="4" && map[w][h]=="5" && map[w][h+1]=="6")
|
||||
else if (map[w][h - 1] == "4" && map[w][h] == "5" && map[w][h + 1] == "6")
|
||||
spClass = "leftRight_5";
|
||||
else if(map[w][h]=="6")
|
||||
else if (map[w][h] == "6")
|
||||
spClass = "grass";
|
||||
else if((map[w][h+1]=="1" && map[w][h]=="1" && map[w+1][h]=="1") || (map[w][h-1]=="1" && map[w][h]=="1" && map[w+1][h]=="1") || (map[w-1][h]=="1" && map[w][h]=="1" && map[w][h+1]=="1") || (map[w-1][h]=="1" && map[w][h]=="1" && map[w][h-1]=="1"))
|
||||
else if ((map[w][h + 1] == "1" && map[w][h] == "1" && map[w + 1][h] == "1") || (map[w][h - 1] == "1" && map[w][h] == "1" && map[w + 1][h] == "1") || (map[w - 1][h] == "1" && map[w][h] == "1" && map[w][h + 1] == "1") || (map[w - 1][h] == "1" && map[w][h] == "1" && map[w][h - 1] == "1"))
|
||||
spClass = "water";
|
||||
else if(map[w][h+1]=="2" && map[w][h]=="2" && map[w+1][h]=="2")
|
||||
else if (map[w][h + 1] == "2" && map[w][h] == "2" && map[w + 1][h] == "2")
|
||||
spClass = "leftRightT_2";
|
||||
else if(map[w][h+1]=="3" && map[w][h]=="3" && map[w+1][h]=="3")
|
||||
else if (map[w][h + 1] == "3" && map[w][h] == "3" && map[w + 1][h] == "3")
|
||||
spClass = "leftRightT_3";
|
||||
else if(map[w][h+1]=="5" && map[w][h]=="5" && map[w+1][h]=="5")
|
||||
else if (map[w][h + 1] == "5" && map[w][h] == "5" && map[w + 1][h] == "5")
|
||||
spClass = "leftRightT_5";
|
||||
else if(map[w-1][h]=="0" && map[w][h]=="1" && map[w+1][h]=="2")
|
||||
else if (map[w - 1][h] == "0" && map[w][h] == "1" && map[w + 1][h] == "2")
|
||||
spClass = "topDown_1";
|
||||
else if(map[w-1][h]=="1" && map[w][h]=="2" && map[w+1][h]=="3")
|
||||
else if (map[w - 1][h] == "1" && map[w][h] == "2" && map[w + 1][h] == "3")
|
||||
spClass = "topDown_2";
|
||||
else if(map[w-1][h]=="2" && map[w][h]=="3" && map[w+1][h]=="4")
|
||||
else if (map[w - 1][h] == "2" && map[w][h] == "3" && map[w + 1][h] == "4")
|
||||
spClass = "topDown_3";
|
||||
else if(map[w-1][h]=="4" && map[w][h]=="5" && map[w+1][h]=="6")
|
||||
else if (map[w - 1][h] == "4" && map[w][h] == "5" && map[w + 1][h] == "6")
|
||||
spClass = "topDown_5";
|
||||
else if(map[w][h+1]=="0" && map[w][h]=="1" && map[w][h-1]=="2")
|
||||
else if (map[w][h + 1] == "0" && map[w][h] == "1" && map[w][h - 1] == "2")
|
||||
spClass = "rightLeft_1";
|
||||
else if(map[w][h+1]=="1" && map[w][h]=="2" && map[w][h-1]=="3")
|
||||
else if (map[w][h + 1] == "1" && map[w][h] == "2" && map[w][h - 1] == "3")
|
||||
spClass = "rightLeft_2";
|
||||
else if(map[w][h+1]=="2" && map[w][h]=="3" && map[w][h-1]=="4")
|
||||
else if (map[w][h + 1] == "2" && map[w][h] == "3" && map[w][h - 1] == "4")
|
||||
spClass = "rightLeft_3";
|
||||
else if(map[w][h+1]=="4" && map[w][h]=="5" && map[w][h-1]=="6")
|
||||
else if (map[w][h + 1] == "4" && map[w][h] == "5" && map[w][h - 1] == "6")
|
||||
spClass = "rightLeft_5";
|
||||
else if(map[w][h-1]=="2" && map[w][h]=="2" && map[w+1][h]=="2")
|
||||
else if (map[w][h - 1] == "2" && map[w][h] == "2" && map[w + 1][h] == "2")
|
||||
spClass = "rightLeftT_2";
|
||||
else if(map[w][h-1]=="3" && map[w][h]=="3" && map[w+1][h]=="3")
|
||||
else if (map[w][h - 1] == "3" && map[w][h] == "3" && map[w + 1][h] == "3")
|
||||
spClass = "rightLeftT_3";
|
||||
else if(map[w][h-1]=="5" && map[w][h]=="5" && map[w+1][h]=="5")
|
||||
else if (map[w][h - 1] == "5" && map[w][h] == "5" && map[w + 1][h] == "5")
|
||||
spClass = "rightLeftT_5";
|
||||
else if(map[w+1][h]=="0" && map[w][h]=="1" && map[w-1][h]=="2")
|
||||
else if (map[w + 1][h] == "0" && map[w][h] == "1" && map[w - 1][h] == "2")
|
||||
spClass = "downTop_1";
|
||||
else if(map[w+1][h]=="1" && map[w][h]=="2" && map[w-1][h]=="3")
|
||||
else if (map[w + 1][h] == "1" && map[w][h] == "2" && map[w - 1][h] == "3")
|
||||
spClass = "downTop_2";
|
||||
else if(map[w+1][h]=="2" && map[w][h]=="3" && map[w-1][h]=="4")
|
||||
else if (map[w + 1][h] == "2" && map[w][h] == "3" && map[w - 1][h] == "4")
|
||||
spClass = "downTop_3";
|
||||
else if(map[w+1][h]=="4" && map[w][h]=="5" && map[w-1][h]=="6")
|
||||
else if (map[w + 1][h] == "4" && map[w][h] == "5" && map[w - 1][h] == "6")
|
||||
spClass = "downTop_5";
|
||||
else if(map[w][h+1]=="2" && map[w][h]=="2" && map[w-1][h]=="2")
|
||||
else if (map[w][h + 1] == "2" && map[w][h] == "2" && map[w - 1][h] == "2")
|
||||
spClass = "leftRightB_2";
|
||||
else if(map[w][h+1]=="3" && map[w][h]=="3" && map[w-1][h]=="3")
|
||||
else if (map[w][h + 1] == "3" && map[w][h] == "3" && map[w - 1][h] == "3")
|
||||
spClass = "leftRightB_3";
|
||||
else if(map[w][h+1]=="5" && map[w][h]=="5" && map[w-1][h]=="5")
|
||||
else if (map[w][h + 1] == "5" && map[w][h] == "5" && map[w - 1][h] == "5")
|
||||
spClass = "leftRightB_5";
|
||||
else if(map[w][h-1]=="2" && map[w][h]=="2" && map[w-1][h]=="2")
|
||||
else if (map[w][h - 1] == "2" && map[w][h] == "2" && map[w - 1][h] == "2")
|
||||
spClass = "rightLeftB_2";
|
||||
else if(map[w][h-1]=="3" && map[w][h]=="3" && map[w-1][h]=="3")
|
||||
else if (map[w][h - 1] == "3" && map[w][h] == "3" && map[w - 1][h] == "3")
|
||||
spClass = "rightLeftB_3";
|
||||
else if(map[w][h-1]=="5" && map[w][h]=="5" && map[w-1][h]=="5")
|
||||
else if (map[w][h - 1] == "5" && map[w][h] == "5" && map[w - 1][h] == "5")
|
||||
spClass = "rightLeftB_5";
|
||||
|
||||
cssMap[w][h] = spClass;
|
||||
cssMap[w][h] = spClass;
|
||||
}
|
||||
}
|
||||
return cssMap;
|
||||
return cssMap;
|
||||
}
|
||||
|
@ -11,8 +11,8 @@ app.use(express.static(__dirname + '/'));
|
||||
var server = require('http').Server(app);
|
||||
var io = require('socket.io')(server);
|
||||
var map = require("./s_map.js");
|
||||
var mapWidth = 500;
|
||||
var mapHeight = 500;
|
||||
var mapWidth = 100;
|
||||
var mapHeight = 100;
|
||||
var maxX = mapWidth * 32;
|
||||
var maxY = mapHeight * 32;
|
||||
var newmap = map.generateMap(mapWidth,mapHeight);
|
||||
|
Loading…
x
Reference in New Issue
Block a user