updated 来回穿越,NPC消失问题解决
This commit is contained in:
parent
a8aece5173
commit
8f7ce44514
6
game.js
6
game.js
@ -100,8 +100,8 @@ function Game(id,options){
|
||||
};
|
||||
//画布坐标转地图坐标
|
||||
Map.prototype.position2coord = function(x,y){
|
||||
var fx = (x-this.x)%this.size-this.size/2;
|
||||
var fy = (y-this.y)%this.size-this.size/2;
|
||||
var fx = Math.abs(x-this.x)%this.size-this.size/2;
|
||||
var fy = Math.abs(y-this.y)%this.size-this.size/2;
|
||||
return {
|
||||
x:Math.floor((x-this.x)/this.size),
|
||||
y:Math.floor((y-this.y)/this.size),
|
||||
@ -139,7 +139,7 @@ function Game(id,options){
|
||||
var new_list = [];
|
||||
var next = function(from,to){
|
||||
if(!finded){
|
||||
var value = typeof options.map[to.y][to.x] !='undefined'?options.map[to.y][to.x]:-1;
|
||||
var value = options.map[to.y]&&typeof options.map[to.y][to.x] !='undefined'?options.map[to.y][to.x]:-1;
|
||||
if(value!=1){ //当前点是否可以走
|
||||
if(value==-1){
|
||||
to.x = (to.x+x_length)%x_length;
|
||||
|
2
index.js
2
index.js
@ -290,6 +290,7 @@
|
||||
});
|
||||
if(this.path.length){
|
||||
this.vector = this.path[0];
|
||||
}
|
||||
if(this.vector.change){ //是否转变方向
|
||||
this.coord.x = this.vector.x;
|
||||
this.coord.y = this.vector.y;
|
||||
@ -297,7 +298,6 @@
|
||||
this.x = pos.x;
|
||||
this.y = pos.y;
|
||||
}
|
||||
}
|
||||
if(this.vector.x>this.coord.x){
|
||||
this.orientation = 0;
|
||||
}else if(this.vector.x<this.coord.x){
|
||||
|
Loading…
x
Reference in New Issue
Block a user