updated 对象允许穿越
This commit is contained in:
parent
99f8b482d2
commit
6ad13f8bd4
10
game.js
10
game.js
@ -138,7 +138,14 @@ function Game(id,options){
|
||||
var _render = function(list){
|
||||
var new_list = [];
|
||||
var next = function(from,to){
|
||||
if(_self.get(to.x,to.y)==0&&!finded){ //当前点是否可以走
|
||||
if(!finded){
|
||||
var value = _self.get(to.x,to.y);
|
||||
if(value!=1){ //当前点是否可以走
|
||||
if(value==-1){
|
||||
to.x = (to.x+x_length)%x_length;
|
||||
to.y = (to.y+y_length)%y_length;
|
||||
to.change = 1;
|
||||
}
|
||||
if(to.x==options.end.x&&to.y==options.end.y){
|
||||
steps[to.y][to.x] = from;
|
||||
finded = true;
|
||||
@ -147,6 +154,7 @@ function Game(id,options){
|
||||
new_list.push(to);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
for(var i=0,len=list.length;i<len;i++){
|
||||
var current = list[i];
|
||||
|
45
index.js
45
index.js
@ -356,6 +356,13 @@
|
||||
});
|
||||
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;
|
||||
var pos = map.coord2position(this.coord.x,this.coord.y);
|
||||
this.x = pos.x;
|
||||
this.y = pos.y;
|
||||
}
|
||||
}
|
||||
if(this.vector.x>this.coord.x){
|
||||
this.orientation = 1;
|
||||
@ -386,10 +393,19 @@
|
||||
context.fillStyle = '#F00';
|
||||
context.beginPath();
|
||||
context.arc(this.x,this.y,this.width*.5,0,Math.PI,true);
|
||||
switch(this.times%2){
|
||||
case 0:
|
||||
context.lineTo(this.x-this.width*.5,this.y+this.height*.4);
|
||||
context.quadraticCurveTo(this.x-this.width*.4,this.y+this.height*.5,this.x-this.width*.2,this.y+this.height*.3);
|
||||
context.quadraticCurveTo(this.x,this.y+this.height*.5,this.x+this.width*.2,this.y+this.height*.3);
|
||||
context.quadraticCurveTo(this.x+this.width*.4,this.y+this.height*.5,this.x+this.width*.5,this.y+this.height*.4);
|
||||
break;
|
||||
case 1:
|
||||
context.lineTo(this.x-this.width*.5,this.y+this.height*.3);
|
||||
context.quadraticCurveTo(this.x-this.width*.25,this.y+this.height*.5,this.x,this.y+this.height*.3);
|
||||
context.quadraticCurveTo(this.x+this.width*.25,this.y+this.height*.5,this.x+this.width*.5,this.y+this.height*.3);
|
||||
break;
|
||||
}
|
||||
context.fill();
|
||||
context.closePath();
|
||||
context.fillStyle = '#FFF';
|
||||
@ -402,14 +418,39 @@
|
||||
context.fill();
|
||||
context.closePath();
|
||||
context.fillStyle = '#00F';
|
||||
switch(this.times%4){
|
||||
case 2:
|
||||
case 0:
|
||||
context.beginPath();
|
||||
context.arc(this.x-this.width*.15,this.y-this.height*.28,this.width*.07,0,2*Math.PI,false);
|
||||
context.arc(this.x-this.width*.15,this.y-this.height*.27,this.width*.07,0,2*Math.PI,false);
|
||||
context.fill();
|
||||
context.closePath();
|
||||
context.beginPath();
|
||||
context.arc(this.x+this.width*.15,this.y-this.height*.28,this.width*.07,0,2*Math.PI,false);
|
||||
context.arc(this.x+this.width*.15,this.y-this.height*.27,this.width*.07,0,2*Math.PI,false);
|
||||
context.fill();
|
||||
context.closePath();
|
||||
break;
|
||||
case 1:
|
||||
context.beginPath();
|
||||
context.arc(this.x-this.width*.17,this.y-this.height*.25,this.width*.07,0,2*Math.PI,false);
|
||||
context.fill();
|
||||
context.closePath();
|
||||
context.beginPath();
|
||||
context.arc(this.x+this.width*.13,this.y-this.height*.25,this.width*.07,0,2*Math.PI,false);
|
||||
context.fill();
|
||||
context.closePath();
|
||||
break;
|
||||
case 3:
|
||||
context.beginPath();
|
||||
context.arc(this.x-this.width*.13,this.y-this.height*.25,this.width*.07,0,2*Math.PI,false);
|
||||
context.fill();
|
||||
context.closePath();
|
||||
context.beginPath();
|
||||
context.arc(this.x+this.width*.17,this.y-this.height*.25,this.width*.07,0,2*Math.PI,false);
|
||||
context.fill();
|
||||
context.closePath();
|
||||
break;
|
||||
}
|
||||
}
|
||||
});
|
||||
stage.bind('keydown',function(e){
|
||||
|
Loading…
x
Reference in New Issue
Block a user