发布文章

您的位置:首页 -网站建设 - 内容


本周排行

最新更新


javascript碰撞

2008-8-22
  

   <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<!-- saved from url=(0047)http://www.dhteumeuleu.com/dhtml/Falling-X.html -->
<HTML><HEAD><TITLE>once upon a time - Interactive DHTML art-demos</TITLE>
<FCK:META http-equiv=Content-Type content="text/html; charset=gb2312" />
<FCK:META content="Gerard Ferrandez at http://www.dhteumeuleu.com" name=author />
<FCK:META http-equiv=imagetoolbar content=no />
<STYLE type=text/css>BODY {
PADDING-RIGHT: 0px; PADDING-LEFT: 0px; BACKGROUND: #000000; LEFT: 0px; PADDING-BOTTOM: 0px; MARGIN: 0px; OVERFLOW: hidden; WIDTH: 100%; CURSOR: url('http://www.dhteumeuleu.com/no.cur'); PADDING-TOP: 0px; POSITION: absolute; TOP: 0px; HEIGHT: 100%
}
SPAN {
POSITION: absolute
}
</STYLE>
<SCRIPT type=text/javascript><!--
// ====================================================
// script: Gerard Ferrandez - Ge-1-doot - DECEMBER 2K4
// http://www.dhteumeuleu.com/
// crossbrowser: IE6 - Firefox - Opera - NS7
// ====================================================

window.onerror = new Function("return true")
var O   = new Array()
var SH  = SW = SPA = SO = xm = ym = XQ = YQ = YB = XB = 0
var pS  = 25
var pQ  = 100
var pQ2 = pQ / 2
var pS2 = pS / 2

function CObj(N){
 this.N = N
 o = document.createElement("span")
 SPA.appendChild(o)
 with(o.style){
  top = -pS
  width = pS
  height = pS
  fontSize = "1px"
  background = "#000000"
  border = "gray solid 1px"
 }
 this.pO = o.style
 this.pX = 0
 this.pY = 1000
 this.zX = 0
 this.zY = 1
 this.Li = false
 
 this.run = function () {
  with (this) {
   zX *= .95
   pY += zY
   pX += zX
   zY += .1 + N * .001
   if(pY>SH){
    pY = -pS
    pX = Math.round(Math.random() * SW)
    zY = 0
    zX = 0
    pO.background = "#000000"
   }
   if(pX >= XQ - pS2 && pX <= XQ + pQ + pS2 && pY >= YQ - pS && pY <= YQ + pQ){
    pY -= zY
    zX += ((pX >= XQ + pQ2)?1:-1) * (.5 * zY + Math.abs(YQ - YB) * .2)
    if(pY < YQ - (YQ - YB)) pY = YQ - pS, zY = 0; else pX += XQ - XB;
    if(!Li){
     Li = true
     pO.background = "#FFFFFF"
     setTimeout("O["+N+"].Li=false;O["+N+"].pO.background='#000000'", 1200)
    }
   }
   pO.left = pX - pS2
   pO.top  = pY
   setTimeout("O["+N+"].run()", 16)
  }
 }
}
function pQM(){
 YB = YQ
 XB = XQ
 XQ = SO.left = xm - pQ2
 YQ = SO.top  = ym - pQ2
 setTimeout(pQM, 16)
}

function resize() {
 with(SPA.style){
  L = left = Math.round(-1+(document.body.offsetWidth - SW) / 2)
  H = top  = Math.round(-1+(document.body.offsetHeight - SH) / 2)
  width    = SW
  height   = SH
 }
}
onresize = resize

onload = function (){
 document.onmousemove = function(e){
  if (window.event) e = window.event
  xm = (e.x || e.clientX) - L
  ym = (e.y || e.clientY) - H
 }
 SPA = document.getElementById("SPAN")
 SO  = document.getElementById("SPLASH").style
 SO.width  = pQ
 SO.height = pQ
 SH  = document.body.offsetHeight
 SW  = pQ - pS2
 SX  = Math.round(SW / pS) - 1
 xm  = SW / 2
 ym  = SH / 2
 resize()
 pQM()
 for(j=0;j<60;j++){
  O[j] = new CObj(j)
  setTimeout("O["+j+"].run()",j * 123)
 }
}
//-->
</SCRIPT>
<FCK:META content="MSHTML 6.00.3790.4210" name=GENERATOR /></HEAD>
<BODY>
<DIV id=SPAN style="BACKGROUND: #222222; POSITION: absolute">
<DIV id=SPLASH
style="BORDER-RIGHT: gray 1px solid; BORDER-TOP: gray 1px solid; FONT-SIZE: 1px; BACKGROUND: #000000; BORDER-LEFT: gray 1px solid; BORDER-BOTTOM: gray 1px solid; POSITION: absolute; TOP: -1000px"></DIV></DIV><div style="font-size:16px;"><a href="http://www.tryjs.cn" _fcksavedurl="http://www.tryjs.cn">javascript仓库</a></div></body></HTML>


如一

来源:www

收藏本页 关闭窗口