DHTML死亡颜色:< URL:http://www.in fimum.dk/HTML/rasterTriangleDOM.html> ''没有判断的信仰只会降低精神神圣。'' if mpdef[0+yy+y] is undefined, the second lookup fails. /L--Lasse Reichstein Nielsen - lr*@hotpop.comDHTML Death Colors: <URL:http://www.infimum.dk/HTML/rasterTriangleDOM.html>''Faith without judgement merely degrades the spirit divine.'' 函数getImage(id,x1,y1){ // shiftys来计算所有指南针方向面 if((ff == 0) ||(ff == 1)){x2 = x1; y2 = y1; } if((ff == 2)||(ff == 3)){x2 = -y1; y2 = x1; } if((ff == 4)||(ff == 5)){x2 = -x1; y2 = -y1; } if((ff == 6)||(ff == 7)){x2 = y1; y2 = -x1; } //检测未定义的地图位置 if((0 + yy + y2< 0)||(0 + xx + x2< 0)||( 1 + yy + y2> mpdef.length)||(1 + xx + x2> mpdef [0] .length)){ document.getElementById( id).src = terrdef [nullterr]; } else { document.getElementById(id).src = terrdef [mpdef [ 0 + yy + y2] [0 + xx + x2]]; } } 上面是我现在使用的,它似乎工作。如果您感兴趣的话,上面的内容正在[ www.lajzar.co.uk/midnight ]。 (箭头键导航,或使用角落里的按钮)。 两个提出疑问... 1)我肯定有4个并行if语句不是特别有效,但我不确定一个更好的解决方案,正确检查所有四个地图边缘。 2)我认为可能有一种更有效的方法来解释8 可能的面板。 - - Fabian 经常访问我的网站并且长期使用! http://www.lajzar.co.uk function getImage(id,x1,y1) {// shiftys to account for all compass direction facingsif ((ff==0) || (ff==1)) { x2 = x1; y2 = y1; }if ((ff==2) || (ff==3)) { x2 = -y1; y2 = x1; }if ((ff==4) || (ff==5)) { x2 = -x1; y2 = -y1; }if ((ff==6) || (ff==7)) { x2 = y1; y2 = -x1; }// detect undefined map locationsif ((0 + yy + y2 < 0) || (0 + xx + x2 < 0) || (1 + yy + y2 >mpdef.length) || (1 + xx + x2 > mpdef[0].length)) {document.getElementById(id).src = terrdef[ nullterr ];}else {document.getElementById(id).src = terrdef[ mpdef[0 + yy + y2][0 + xx +x2] ];}} The above is what I am using now, and it seems to work. In case you''reinterested, the above is being used at [ www.lajzar.co.uk/midnight ].(arrow keys to navigate, or use the buttons in the corner).Two points to question... 1) I''m sure having 4 parallel if statements is not particularlyefficient, but I''m not sure of a better solution that checks all fourmap edges properly. 2) I think there is probably a more efficient way to account for the 8possible facings.----FabianVisit my website often and for long periods! http://www.lajzar.co.uk 这篇关于MyArray [3] [ - 2]失败(quelle surprise),怎么检测到这个?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 10-29 04:35