function iMan(x,y,k){
Man = Base.appendChild(document.createElement("<img alt='Man' src='boxman.bmp' style='position:absolute;left:"+x*MapW+";top:"+y*MapH+";width:"+MapW+";height:"+MapH+";' class='Man'>"));
Man.x = x
Man.y = y
MainMap[y][x] = (k==0)?' ':'.';
}
function init(){
MainMap = [];
RePlayTime = 10;
MapW = MapH = 30;
PushScrollNo = 30;
BoxCompletes = 0;
TotalBox = 0;
Timer = null;
canMove = true
BoxMoves = 0;
Count = -1;
BackRecord = [];
BoxMoveInfo.value = 0;
ManMoveInfo.value = 0;
LevelInfo.value = parseInt(useLevel)+1;
}
function Dir(x,y,k){
if(!canMove) return
var ManFront = MainMap[y+parseInt(Man.y)][x+parseInt(Man.x)];
if(ManFront==' ' || ManFront=='.')
if(k!=null)Move1(x,y,k.toLowerCase());
else Move1(x,y);
else{
if(typeof(ManFront)=='object'){
var ManFrontFront = MainMap[2*y+parseInt(Man.y)][2*x+parseInt(Man.x)];
if(ManFrontFront == ' '){
if(k!=null)Move1(x,y,k.toUpperCase());
else Move1(x,y);Move2(ManFront,x,y);
}
else if(ManFrontFront == '.'){
if(k!=null)Move1(x,y,k.toUpperCase());
else Move1(x,y);Move3(ManFront,x,y);
}
BoxMoves++
}
}
}
function Move1(x,y,k){
if(k != null){
BackRecord[++Count] = k
BackRecord.length = Count+1
}
Man.x = x+parseInt(Man.x);
Man.y = y+parseInt(Man.y);
Man.style.left = Man.x*MapW;
Man.style.top = Man.y*MapH;
}
function Move2(obj,x,y){
obj.style.left = (x+Man.x)*MapW;
obj.style.top = (y+Man.y)*MapH;
MainMap[y+parseInt(Man.y)][x+parseInt(Man.x)] = obj;
if(obj.complete == 0) MainMap[Man.y][Man.x]=' ';
else{
MainMap[Man.y][Man.x] = '.';
BoxCompletes --;
}
obj.complete = 0;
}
文章来源于领测软件测试网 https://www.ltesting.net/