add chest to the game
This commit is contained in:
parent
1cd9762a3b
commit
7429b1ae6d
40
css/main.css
40
css/main.css
@ -1,34 +1,35 @@
|
|||||||
.sprite {
|
.sprite {
|
||||||
width: 32px;
|
width: 32px;
|
||||||
height: 32px;
|
height: 32px;
|
||||||
position: absolute;
|
position: absolute;
|
||||||
}
|
}
|
||||||
|
|
||||||
.animate {
|
.animate {
|
||||||
background-position:left bottom !important;
|
background-position: left bottom !important;
|
||||||
}
|
}
|
||||||
|
|
||||||
.spriteUtils{
|
.spriteUtils {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
-webkit-transform: scale(0.7);
|
-webkit-transform: scale(0.7);
|
||||||
transform: scale(0.7);
|
transform: scale(0.7);
|
||||||
transform-origin: 0;
|
transform-origin: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
.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 {
|
||||||
width: 60px;
|
width: 60px;
|
||||||
height: 60px;
|
height: 60px;
|
||||||
z-index: 110 !important;
|
z-index: 110 !important;
|
||||||
background: url(../img/objectlayer.png) 315px -70px;
|
background: url(../img/objectlayer.png) 315px -70px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.stone1{
|
.stone1 {
|
||||||
width: 32px;
|
width: 32px;
|
||||||
height: 35px;
|
height: 35px;
|
||||||
background: url(../img/objectlayer.png) 158px -65px;
|
background: url(../img/objectlayer.png) 158px -65px;
|
||||||
@ -48,7 +49,7 @@
|
|||||||
top: -13px;
|
top: -13px;
|
||||||
left: -13px;
|
left: -13px;
|
||||||
background: url(../img/guy_sprite.png) 0px 0px;
|
background: url(../img/guy_sprite.png) 0px 0px;
|
||||||
-webkit-transform: scale(0.7);
|
-webkit-transform: scale(0.7);
|
||||||
transform: scale(0.7);
|
transform: scale(0.7);
|
||||||
transform-origin: 0;
|
transform-origin: 0;
|
||||||
}
|
}
|
||||||
@ -150,23 +151,36 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
#main {
|
#main {
|
||||||
-webkit-transform: scale(1.5);
|
-webkit-transform: scale(1.5);
|
||||||
transform: scale(2);
|
transform: scale(2);
|
||||||
transform-origin: 0;
|
transform-origin: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
.fass{
|
.fass {
|
||||||
width: 32px;
|
width: 32px;
|
||||||
height: 43px;
|
height: 43px;
|
||||||
background: url(../img/objectlayer.png) 157px -18px;
|
background: url(../img/objectlayer.png) 157px -18px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.forest{
|
.forest {
|
||||||
width: 46px;
|
width: 46px;
|
||||||
height: 46px;
|
height: 46px;
|
||||||
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
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 = {
|
module.exports = {
|
||||||
generateMap: function(width, height) {
|
generateMap: function (width, height) {
|
||||||
var map = [];
|
var map = [];
|
||||||
var utilMap = [];
|
var utilMap = [];
|
||||||
|
|
||||||
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] + "";
|
||||||
for(var w=1;w<map.length-1;w++) {
|
for (var w = 1; w < map.length - 1; w++) {
|
||||||
for(var h=1;h<map[w].length-1;h++) {
|
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)) {
|
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
|
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 exP = 80;
|
//return map;
|
||||||
for(var w=1;w<width-1;w++) {
|
|
||||||
for(var h=1;h<height-1;h++) {
|
|
||||||
if(orgMap[w][h]=="#") {
|
for (var w = 0; w < width; w++) {
|
||||||
if(rand(exP)) map[w-1][h]="#"
|
map[w] = [];
|
||||||
if(rand(exP)) map[w+1][h]="#"
|
utilMap[w] = [];
|
||||||
if(rand(exP)) map[w][h-1]="#"
|
for (var h = 0; h < height; h++) {
|
||||||
if(rand(exP)) map[w][h+1]="#"
|
map[w][h] = "0";
|
||||||
if(rand(exP)) map[w-1][h-1]="#"
|
utilMap[w][h] = "";
|
||||||
if(rand(exP)) map[w-1][h+1]="#"
|
if (Math.random() < 0.0009)
|
||||||
if(rand(exP)) map[w+1][h-1]="#"
|
map[w][h] = "#";
|
||||||
if(rand(exP)) map[w+1][h+1]="#"
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
//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) {
|
function rand(p) {
|
||||||
if(p > Math.random()*100)
|
if (p > Math.random() * 100)
|
||||||
return true;
|
return true;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
function addCssClass(map) {
|
function addCssClass(map) {
|
||||||
var cssMap = [];
|
var cssMap = [];
|
||||||
for(var w=0;w<map.length;w++) {
|
for (var w = 0; w < map.length; w++) {
|
||||||
cssMap[w] = [];
|
cssMap[w] = [];
|
||||||
for(var h=0;h<map[w].length;h++) {
|
for (var h = 0; h < map[w].length; h++) {
|
||||||
var spClass = "ground_";
|
var spClass = "ground_";
|
||||||
if(map[w][h]=="0" || (w<=0 || h<=0 || w>=map.length-1 || h>=map[w].length-1)) {
|
if (map[w][h] == "0" || (w <= 0 || h <= 0 || w >= map.length - 1 || h >= map[w].length - 1)) {
|
||||||
if(Math.random()<0.001)
|
if (Math.random() < 0.001)
|
||||||
spClass = "water_1";
|
spClass = "water_1";
|
||||||
else if(Math.random()<0.001)
|
else if (Math.random() < 0.001)
|
||||||
spClass = "water_2";
|
spClass = "water_2";
|
||||||
else
|
else
|
||||||
spClass = "water";
|
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")) {
|
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][h + 1] == "2" && map[w + 1][h] == "2") {
|
||||||
if(map[w-1][h+1]=="1" && map[w+1][h-1]=="2")
|
if (map[w - 1][h + 1] == "1" && map[w + 1][h - 1] == "2")
|
||||||
spClass = "topDown_1";
|
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";
|
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";
|
spClass = "leftRightTT_1";
|
||||||
else
|
else
|
||||||
spClass = "leftRightT_1";
|
spClass = "leftRightT_1";
|
||||||
@ -189,13 +207,13 @@ function addCssClass(map) {
|
|||||||
else
|
else
|
||||||
spClass = "leftRightT_1";
|
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")) {
|
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][h - 1] == "2" && map[w + 1][h] == "2") {
|
||||||
if(map[w-1][h-1]=="1" && map[w+1][h+1]=="2")
|
if (map[w - 1][h - 1] == "1" && map[w + 1][h + 1] == "2")
|
||||||
spClass = "topDown_1";
|
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";
|
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";
|
spClass = "rightLeftTT_1";
|
||||||
else
|
else
|
||||||
spClass = "rightLeftT_1";
|
spClass = "rightLeftT_1";
|
||||||
@ -203,13 +221,13 @@ function addCssClass(map) {
|
|||||||
else
|
else
|
||||||
spClass = "rightLeftT_1";
|
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")) {
|
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][h + 1] == "2" && map[w - 1][h] == "2") {
|
||||||
if(map[w+1][h+1]=="1" && map[w-1][h-1]=="2")
|
if (map[w + 1][h + 1] == "1" && map[w - 1][h - 1] == "2")
|
||||||
spClass = "downTop_1";
|
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";
|
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";
|
spClass = "rightLeftBB_1";
|
||||||
else
|
else
|
||||||
spClass = "rightLeftB_1";
|
spClass = "rightLeftB_1";
|
||||||
@ -217,13 +235,13 @@ function addCssClass(map) {
|
|||||||
else
|
else
|
||||||
spClass = "rightLeftB_1";
|
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")) {
|
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][h - 1] == "2" && map[w - 1][h] == "2") {
|
||||||
if(map[w+1][h-1]=="1" && map[w-1][h+1]=="2")
|
if (map[w + 1][h - 1] == "1" && map[w - 1][h + 1] == "2")
|
||||||
spClass = "downTop_1";
|
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";
|
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";
|
spClass = "leftRightBB_1";
|
||||||
else
|
else
|
||||||
spClass = "leftRightB_1";
|
spClass = "leftRightB_1";
|
||||||
@ -232,99 +250,99 @@ function addCssClass(map) {
|
|||||||
spClass = "leftRightB_1";
|
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";
|
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";
|
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";
|
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";
|
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";
|
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";
|
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";
|
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";
|
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";
|
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";
|
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";
|
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";
|
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";
|
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";
|
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";
|
spClass = "leftRight_3";
|
||||||
else if(map[w][h]=="4")
|
else if (map[w][h] == "4")
|
||||||
spClass = "ground";
|
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";
|
spClass = "leftRight_5";
|
||||||
else if(map[w][h]=="6")
|
else if (map[w][h] == "6")
|
||||||
spClass = "grass";
|
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";
|
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";
|
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";
|
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";
|
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";
|
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";
|
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";
|
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";
|
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";
|
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";
|
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";
|
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";
|
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";
|
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";
|
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";
|
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";
|
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";
|
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";
|
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";
|
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";
|
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";
|
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";
|
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";
|
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";
|
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";
|
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 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);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user