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){
|
Map.prototype.position2coord = function(x,y){
|
||||||
var fx = (x-this.x)%this.size-this.size/2;
|
var fx = Math.abs(x-this.x)%this.size-this.size/2;
|
||||||
var fy = (y-this.y)%this.size-this.size/2;
|
var fy = Math.abs(y-this.y)%this.size-this.size/2;
|
||||||
return {
|
return {
|
||||||
x:Math.floor((x-this.x)/this.size),
|
x:Math.floor((x-this.x)/this.size),
|
||||||
y:Math.floor((y-this.y)/this.size),
|
y:Math.floor((y-this.y)/this.size),
|
||||||
@ -139,7 +139,7 @@ function Game(id,options){
|
|||||||
var new_list = [];
|
var new_list = [];
|
||||||
var next = function(from,to){
|
var next = function(from,to){
|
||||||
if(!finded){
|
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){ //当前点是否可以走
|
||||||
if(value==-1){
|
if(value==-1){
|
||||||
to.x = (to.x+x_length)%x_length;
|
to.x = (to.x+x_length)%x_length;
|
||||||
|
14
index.js
14
index.js
@ -290,13 +290,13 @@
|
|||||||
});
|
});
|
||||||
if(this.path.length){
|
if(this.path.length){
|
||||||
this.vector = this.path[0];
|
this.vector = this.path[0];
|
||||||
if(this.vector.change){ //是否转变方向
|
}
|
||||||
this.coord.x = this.vector.x;
|
if(this.vector.change){ //是否转变方向
|
||||||
this.coord.y = this.vector.y;
|
this.coord.x = this.vector.x;
|
||||||
var pos = map.coord2position(this.coord.x,this.coord.y);
|
this.coord.y = this.vector.y;
|
||||||
this.x = pos.x;
|
var pos = map.coord2position(this.coord.x,this.coord.y);
|
||||||
this.y = pos.y;
|
this.x = pos.x;
|
||||||
}
|
this.y = pos.y;
|
||||||
}
|
}
|
||||||
if(this.vector.x>this.coord.x){
|
if(this.vector.x>this.coord.x){
|
||||||
this.orientation = 0;
|
this.orientation = 0;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user