站内搜索: 请输入搜索关键词

当前页面: 开发资料首页Javascript 专题Dhtml+Js算法:5个小球运动的简化版,变通实现更简单的飞行的图片

Dhtml+Js算法:5个小球运动的简化版,变通实现更简单的飞行的图片

摘要: Dhtml+Js算法:5个小球运动的简化版,变通实现更简单的飞行的图片



<head>


网页飞行图片

</head>
<body topmargin='2' leftmargin='2'>


<script>
//原作:风云舞,载自:http://www.lshdic.com/bbs
var wid1,hei1,str1="",xx=0,yy=0,xjia=true,yjia=true //定义全局变量,为提高运行速度
wid1=a.offsetWidth-70;hei1=a.offsetHeight-70 //得到容器的宽和高
//首次向容器内塞进1个飞行的图片,图片位置属性是随机的
tempx=Math.round(Math.random()*wid1);tempy=Math.round(Math.random()*hei1);
str1+=""
a.innerHTML=str1; //插入STR1,STR1?个VML球的代码
function play1(){ //播放函数
wid1=a.offsetWidth;hei1=a.offsetHeight
if(wid1-xx<155)xjia=false //到达X极限,值为FALSE
if(xx<5)xjia=true //到达X起点,值为TRUE
if(hei1-yy<155)yjia=false
if(yy<5)yjia=true
if (xjia==true)xx+=5;else xx-=5 //TRUE的话就++,FALSE的话就--
if (yjia==true)yy+=5;else yy-=5
img1.style.left=xx;img1.style.top=yy //更新球的位置
}
setInterval("play1()",10) //10毫秒播放一次,一般CPU保证能消化~~~
</script>
</body>

</td> </tr> <tr> <td vAlign=top align=left height="100%">
↑返回目录
前一篇: Vml+Js算法:完成5个小球在网页运动(碰壁返回)的游戏,详细注释
后一篇: Vml+Dhtml:制作一个应用渐变颜色效果不错的进度条