搏客 Winning
After three days without programming, life becomes meaningless
posts - 46,  comments - 41,  trackbacks - 21

<HTML> 
<HEAD> 
<TITLE>simple solar system</TITLE> 
<SCRIPT LANGUAGE="JavaScript"> 
        
function Sun() 
        

            
this.init=function() 
            

                document.all.Sun.style.top
=222.5
                document.all.Sun.style.left
=362.5
            }
 
        }
 
        
function Earth() 
        

            
this.x=0
            
this.y=0
            
this.setXY=function(x,y){this.x=x-25;this.y=y-25;} 
            
this.Move=function()
            
{
                document.all.Earth.style.top
=this.y;
                document.all.Earth.style.left
=this.x;
            }
 
        }
 
 
        
function Moon() 
        

            
this.x=0
            
this.y=0
            
this.setXY=function(x,y){this.x=x-10;this.y=y-10;} 
            
this.Move=function()
            
{
                document.all.Moon.style.top
=this.y;
                document.all.Moon.style.left
=this.x;
            }
 
        }
 
 
        
function Comet() 
        

            
this.x=0
            
this.y=0
            
this.setXY=function(x,y){this.x=x-15;this.y=y-15;} 
            
this.Move=function()
            
{
                document.all.Comet.style.top
=this.y;
                document.all.Comet.style.left
=this.x;
            }
 
        }
 
 
 
 
        
var t=0
        
var x0=400
        
var y0=260
        
var r1=180
        
var r2=50
 
        
var sun=new Sun(); 
        
var earth=new Earth(); 
        
var moon=new Moon(); 
        
var comet=new Comet(); 
 
        
var cos001=new Array(72); 
        
var sin001=new Array(72); 
        
var cos01=new Array(72); 
        
var sin01=new Array(72); 
 
 
        
for(var i=0;i<72;i++
        

            cos001[i]
=parseInt(x0+r1*Math.cos(0.0174*i*5)); 
            sin001[i]
=parseInt(y0+r1*Math.sin(0.0174*i*5)); 
            cos01[i]
=parseInt(cos001[i]+r2*Math.cos(0.174*i*5)); 
            sin01[i]
=parseInt(sin001[i]+r2*Math.sin(0.174*i*5)); 
        }
 
 
        
function Moving() 
        

                
var j=(t%360)/5
                
var x=cos001[j]; 
                
var y=sin001[j]; 
                
var xx=cos01[j]; 
                
var yy=sin01[j]; 
 
                
var y2=(y+y0)/2
                
var x2=2*x-x0+220
 
                earth.setXY(x,y); 
                moon.setXY(xx,yy); 
                comet.setXY(x2,y2); 
 
                earth.Move(); 
                moon.Move(); 
                comet.Move(); 
                t
=(t+5)%360
                window.setTimeout(
"Moving()",100); 
        }
 
                sun.init(); 
                Moving(); 
 
</SCRIPT> 
</HEAD> 
 
<BODY> 
    
<img src="7.gif" style="position:absolute" width="50" height="50" id="Sun"> 
    
<img src="2.gif" style="position:absolute" id="Earth"> 
    
<img src="2.gif" style="position:absolute" width="20" height="20"  id="Moon"> 
    
<img src="2.gif" style="position:absolute" width="30" height="30"  id="Comet"> 
</BODY> 
</HTML>
posted on 2005-04-11 16:49 搏客 Winning 阅读(576) 评论(0)  编辑 收藏 所属分类: 玩具代码

标题  
姓名  
主页
Email (博主才能看到) 
验证码 *  看不清,换一张 [登录][注册]
内容(请不要发表任何与政治相关的内容)  
  登录  使用高级评论  新用户注册  返回页首  恢复上次提交      
该文被作者在 2005-04-11 16:52 编辑过


相关链接:
 




与我联系

搜索

 

常用链接

随笔分类

随笔档案

积分与排名

  • 积分 - 31219
  • 排名 - 1371

最新评论

阅读排行榜