<!--
http://dwin.net
http://dewin.tk
copyright(c) 1998-2004 dewin all rights reserved
start 2002-10-02 17:50
finish 2002-10-15 22:41
last edit 2003-06-11 18:55
-->
<body>
<style>
.ground{}
.floor{}
.wall{border:2px outset #adff2f;background-color:#888888;z-index:0}
.aim{background-color:#ff69b4;filter:alpha(opacity=100,finishopacity=0,style=3);z-index:0}
.box{background-color:#87cefa;filter:alpha(opacity=0,finishopacity=100,style=3);z-index:1}
.man{background-color:red;z-index:1;filter:filpv}
</style>
<textarea id=info rows=20>rddlllllluurrrdulllddrrrrrruuldlrrdluldddldruuurururrddllluldddlddrruluuuurrurdrdlllulddddrddlluruuuulllluurrrdulllddrrrurdddddldruuuuuululldldrrrurdddduuuululdldrrurdddldr</textarea><br>
<input type=button value='copy' onclick='info.select();document.execcommand("copy")'>
<input type=button value='paste' onclick='info.focus();if(!/[^(l|r|u|d|l|r|u|d)]/g.exec(window.clipboarddata.getdata("text")))document.execcommand("paste")'>
<input type=button value='auto run' onclick='run()'><br><br>
boxes has moved<br><input id=boxmoveinfo readonly> steps<br>
man has moved<br><input id=manmoveinfo readonly> steps
<span id=base style='position:absolute;overflow:hidden'></span>
<script>
function init(){
mainmap = [];
replaytime = 10 //million second
mapw = maph = 30;
pushscrollno = 30;
boxcompletes = 0;
totalbox = 0;
timer = null;
canmove = true
boxmoves = 0;
count = -1;
backrecord = [];
boxmoveinfo.value = 0;
manmoveinfo.value = 0;
}
/*
w = wall
0 = box
@ = box on aim
* = man
# = man on aim
. = aim
= space
*/
map = [];
map[0] = [
'wwwwwwwwwww',
'w w* w',
'w 00000 0 w',
'w w',
'wwwww wwwww',
' w .w ',
' w .w ',
' w...w ',
' w .w ',
' wwwww '
]
function readmap(k){
init();
base.innerhtml = '';
var w=map[k][0].length*mapw
var h=map[k].length*mapw
base.style.width = w;
base.style.height = h;
base.style.left = (w>document.body.clientwidth)?0:(document.body.offsetwidth-w)/2;
base.style.top = 10;
for(var y=0;y<map[k].length;y++){
mainmap[y] = [];
for(var x=0;x<map[k][y].length;x++){
mainmap[y][x] = map[k][y].charat(x);
if(mainmap[y][x]=='w')ihtml(x,y,'wall');
else{
//if(mainmap[y][x]=="|"){ihtml(x,y,'floor');mainmap[y][x]=' '}
//else ihtml(x,y,'ground');
ihtml(x,y,'ground');
switch(mainmap[y][x]){
case '0':ibox(x,y,0);break;
case '.':ihtml(x,y,'aim');break;
case '@':ihtml(x,y,'aim');ibox(x,y,1);boxcompletes++;break;
case '*':iman(x,y,0);break;
case '#':ihtml(x,y,'aim');iman(x,y,1);break;
}
}
}
}
}
function ihtml(x,y,k){
base.insertadjacenthtml("beforeend","<span style='position:absolute;left:"+x*mapw+";top:"+y*maph+";width:"+mapw+";height:"+maph+"' class='"+k+"' x="+x+" y="+y+">");
}
function ibox(x,y,k){
mainmap[y][x] = base.appendchild(document.createelement("<span style='position:absolute;left:"+x*mapw+";top:"+y*maph+";width:"+mapw+";height:"+maph+"' class='box' complete='"+k+"'>"));
totalbox++;
}
function iman(x,y,k){
man = base.appendchild(document.createelement("<img alt='man' src='pic/boxman.gif' 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 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++
}
}