add forest
This commit is contained in:
parent
2942fb98ff
commit
33ddb4316e
14
css/main.css
14
css/main.css
@ -157,10 +157,24 @@
|
|||||||
background: url(../img/objectlayer.png) 157px -18px;
|
background: url(../img/objectlayer.png) 157px -18px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.forest{
|
||||||
|
width: 46px;
|
||||||
|
height: 46px;
|
||||||
|
background: url(../img/ground_tiles.png) -135px -17px;
|
||||||
|
}
|
||||||
|
|
||||||
.water {
|
.water {
|
||||||
background: url(../img/ground_tiles.png) 192px 254px;
|
background: url(../img/ground_tiles.png) 192px 254px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.water_1 {
|
||||||
|
background: url(../img/ground_tiles.png) -1px -1px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.water_2 {
|
||||||
|
background: url(../img/ground_tiles.png) -98px -1px;
|
||||||
|
}
|
||||||
|
|
||||||
.ground {
|
.ground {
|
||||||
background: url(../img/ground_tiles.png) 640px 541px;
|
background: url(../img/ground_tiles.png) 640px 541px;
|
||||||
}
|
}
|
||||||
|
Binary file not shown.
Before Width: | Height: | Size: 222 KiB After Width: | Height: | Size: 232 KiB |
@ -158,7 +158,6 @@ socket.on('setpos', function (allPlayers) {
|
|||||||
picStep++;
|
picStep++;
|
||||||
if(picStep >= 3)
|
if(picStep >= 3)
|
||||||
picStep = 0;
|
picStep = 0;
|
||||||
console.log(top2Btn+"-"+left2right)
|
|
||||||
if(!playerImg.hasClass("guy"+top2Btn+"-"+left2right+"-"+picStep)) {
|
if(!playerImg.hasClass("guy"+top2Btn+"-"+left2right+"-"+picStep)) {
|
||||||
playerImg.removeClass (function (index, className) {
|
playerImg.removeClass (function (index, className) {
|
||||||
return (className.match (/(^|\s)guy\S+/g) || []).join(' ');
|
return (className.match (/(^|\s)guy\S+/g) || []).join(' ');
|
||||||
|
27
s_map.js
27
s_map.js
@ -109,6 +109,12 @@ module.exports = {
|
|||||||
map[w][h] = "6"; //set ground
|
map[w][h] = "6"; //set ground
|
||||||
|
|
||||||
if(Math.random()<0.011) {
|
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";
|
utilMap[w][h] = "flower";
|
||||||
} else if(Math.random()<0.011) {
|
} else if(Math.random()<0.011) {
|
||||||
utilMap[w][h] = "tree1";
|
utilMap[w][h] = "tree1";
|
||||||
@ -121,6 +127,16 @@ module.exports = {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for(var w=0;w<width;w++) {
|
||||||
|
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];
|
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]+"";
|
||||||
@ -134,6 +150,7 @@ module.exports = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
var cssMap = addCssClass(map);
|
var cssMap = addCssClass(map);
|
||||||
|
|
||||||
return {"map": map, "cssMap":cssMap, "utilMap":utilMap};
|
return {"map": map, "cssMap":cssMap, "utilMap":utilMap};
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -150,8 +167,14 @@ function addCssClass(map) {
|
|||||||
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)) {
|
||||||
spClass = "water";
|
if(Math.random()<0.001)
|
||||||
|
spClass = "water_1";
|
||||||
|
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")) {
|
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")
|
||||||
|
@ -126,7 +126,9 @@ function checkPlayerPosition(newX, newY, groundUnderPlayer, player) {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
if(groundUnderPlayer == 7) { //forrest so dont move
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@ -139,6 +141,10 @@ function getGroundUnderPlayer(newX, newY) { //0 = water; 10 = hard ground
|
|||||||
var mapX = Math.floor(newX/32);
|
var mapX = Math.floor(newX/32);
|
||||||
var mapY = Math.floor(newY/32);
|
var mapY = Math.floor(newY/32);
|
||||||
var ground = cssMap[mapY][mapX];
|
var ground = cssMap[mapY][mapX];
|
||||||
|
var util = utilMap[mapY][mapX];
|
||||||
|
if(util == "forest") {
|
||||||
|
return 7;
|
||||||
|
}
|
||||||
var groundSplit = ground.split("_");
|
var groundSplit = ground.split("_");
|
||||||
if(groundSplit.length != 2) {
|
if(groundSplit.length != 2) {
|
||||||
if(ground == "water") {
|
if(ground == "water") {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user