首页
网页特效库
网页特效库
导航菜单
按钮表单
背景特效
时间日期
图片特效
鼠标特效
文本操作
窗口页面
状态栏类
警告对话
综合应用
游戏娱乐
首页
>
特效
>
游戏娱乐
> 正文
JavaScript 跳跳球效果模拟
2010-01-15 游戏娱乐 512℃
<p> <meta content="no" http-equiv="imagetoolbar" /><style type="text/css"> body {cursor:crosshair;margin:0; padding:0; position:absolute; overflow:hidden; background:#000; left:0; top:0; width:100%; height:100%;} img {position:absolute;left:-1000;}</style><script type="text/javascript"><!-- o = new Object(); xm = ym = 0; K = 0; M = 1; img = 0; document.onmousemove = function(e){ if (window.event) e = window.event; xm = (e.x || e.clientX); ym = (e.y || e.clientY); M = 0; } function resize() { nx = document.body.offsetWidth; ny = document.body.offsetHeight; } onresize = resize; // obZ = function(N,img,imgS) { this.N = N; this.W = (N==0)?0:img.width/2; this.x = xm/2; this.y = -this.W; this.vx = 6; this.vy = 0; this.O = document.createElement("img"); this.O.src = img.src; this.O.style.zIndex = 1000-this.W; document.getElementById("SF").appendChild(this.O); } function mainloop(){ for(i=M;i<K;i++){ with(o[i]){ for(j=i+1;j<K;j++){ dx = x-o[j].x; dy = y-o[j].y; d1 = Math.sqrt(dx*dx+dy*dy); d = (W+o[j].W)-d1; if(d>0){ ang = Math.atan2(dy, dx); dx = d * Math.cos(ang); dy = d * Math.sin(ang); if(W>o[j].W || i==0){ o[j].x -= dx; o[j].y -= dy; o[j].vx -= dx; o[j].vy -= dy; } else { x += dx; y += dy; vx += dx; vy += dy; } } } vy+=W/100; y+=vy; if(y>ny-W)vy=-vy,y=ny-W; x+=vx; if(x<W)x=W,vx=-vx; else if(x>nx-W)x=nx-W,vx=-vx; vx*=.99; vy*=.99; if(N==0)x=xm,y=ym,vx=0,vy=0; else{ O.style.left = x-W; O.style.top = y-W; } } } M = 1; setTimeout(mainloop,16); } function creaTobZ(ID){ o[K] = new obZ(K++,img[ID]); } onload = function() { img = document.getElementById("images").getElementsByTagName("img"); resize(); xm = nx / 2; ym = -1000; creaTobZ(0); setTimeout("creaTobZ(0)",500); for(var i=0;i<20;i++)setTimeout("creaTobZ("+(1+(i%(img.length-1)))+")",(i+10)*500); mainloop(); } //--> </script></p> <div id="SF" style="position: absolute; top: 0px; ledt: 0px"> </div> <div id="images" style="visibility: hidden"><img alt="" src="/images/tx/c1.gif" /> <img alt="" src="/images/tx/c2.gif" /> <img alt="" src="/images/tx/c3.gif" /> <img alt="" src="/images/tx/c3.gif" /> <img alt="" src="/images/tx/c4.gif" /> <img alt="" src="/images/tx/c4.gif" /> <img alt="" src="/images/tx/c4.gif" /> <img alt="" src="/images/tx/c4.gif" /></div>
相关特效代码
无相关信息
热门特效代码
JavaScript 跳跳球效果模拟
俄罗斯方块网页版
跳舞的游戏代码
网页代码智力小游戏
双人小游戏代码
推荐特效代码