记得有人用js写过星际争霸游戏。你这个肯定也可以实现。不过很费事!搜索“js星际争霸”,不知道这个对你http://www.junstudio.org/xingji/有没有启发。

解决方案 »

  1.   

    <html>
    <head>
    <title> 鼠標取框 </title>
    <script language="JavaScript">
    var x0;
    var y0;
    var select=false;function Conmousedown()
    {
        x0=document.body.scrollLeft+event.clientX;// 鼠?起始横坐?
        y0=document.body.scrollTop+event.clientY;// 鼠?起始?坐?
        select=true;
    }function document.onmouseup()
    {
    //document.all.img1.click();
        select=false;
    }function document.onselectstart()
    {
        return false;
    }function document.ondrag()
    {
        return false;
    }function Conmousemove()
    {
       if (select)
        {
            dd.style.display='';// 如果鼠?已?正?移?,将??置?可?。
            if(document.body.scrollLeft+event.clientX-x0>0) // 从左向右
            {
                dd.style.left=x0;
                dd.style.width=document.body.scrollLeft+event.clientX-x0-2;
            }
            else // 从右向左
            {
                dd.style.left=document.body.scrollLeft+event.clientX;
                dd.style.width=x0-(document.body.scrollLeft+event.clientX);
            }
            if (document.body.scrollTop+event.clientY-y0>0)// 从上向下
            {
                dd.style.top=y0;
                dd.style.height=document.body.scrollTop+event.clientY-y0;
            }
            else// 从下向上
            {
                dd.style.top=document.body.scrollTop+event.clientY;
                dd.style.height=y0-(document.body.scrollTop+event.clientY);
            }
        }
    }
    </script>
    </head>
    <body>
    <form name="form1">
    <table>
    <tr>
    <td onMouseMove="javascript:Conmousemove()" onMouseDown="JavaScript:Conmousedown();">
    <input type="image" name="img1" id="img1" src="22.jpg" onclick="return false;">
    </td>
    </tr>
    </table>
    <!--table id="dd" style="position:absolute; width:0px; height:0px; z-index:99; border:1px RED Solid; display:none;">
    <tr>
    <td></td>
    </tr>
    </table-->
    <div id="dd" style="position:absolute; width:0px; height:0px; z-index:99; border:1px RED Solid; display:none;"><div>
    </form>
    </body>
    </html>