Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

JavaScript Forum


You are currently viewing our JavaScript Forum as a guest. Please register to participate.
Login



Reply
this.is making me nuts!
Old 05-18-2009, 08:18 PM this.is making me nuts!
Sleeping Troll's Avatar
Ultra Talker

Posts: 351
Name: Butch Begy
Trades: 0
Here is the code snippet:
Code:
 
var numOrbs=50;       //number of Orbs
var iv=.7;            //initial Orb speed
var Orbcollisions=1;    //Orb collisions 1=on, 0=off
var Zeye;           //perspective:distance of eye from box centre
var Zscreen;           //perspective:distance of screen from box centre
var pw,ph,cw,ch;
var Orbsize,Orbsize2;
var xmin,ymin,xmax,ymax,zmin,zmax;
var collisions=new Array();
var collisionpool= new Array();
var vx=new Array();
var vy=new Array();
var vz=new Array();
var px=new Array();
var py=new Array();
var pz=new Array();
var cln=new Array();
var Orb=new Object();
var twa;
var eps=0.01;
var alarm=0;
var offsetx;
var offsety;
var os
function init(){
 var i,im,theta;
  Orbsize=25;
  Orbsize2=4*Orbsize*Orbsize;
  for(i=0;i<numOrbs*2;i++)collisionpool.push(new collision(container));
 resize()  
  for(i=0;i<numOrbs;i++){
   var i,im,theta;
    cln[i]=new Array;
    for(j=0;j<numOrbs;j++)cln[i][j]=0;
    px[i]=-.5*cw;
    py[i]=-.5*ch;
    pz[i]=(zmin);
    theta=Math.PI*2*Math.random();
    phi=Math.asin(Math.random());
    //if(Math.random()>0.5)phi=-phi;
    vx[i]=iv*Math.cos(theta)*Math.cos(phi);
    vy[i]=iv*Math.sin(theta)*Math.cos(phi);
    vz[i]=iv*Math.sin(phi);
  Orb[i]=new OrbCreator(i);
  Orb[i+50]=new OrbCreator(i+50);
  Orb[i+100]=new OrbCreator(i+100);
  }
  document.body.onresize=resize;
  setInterval("anim();",100);
}
 
function OrbCreator(ID){
  var b;
 b=document.createElement("<img src='./images/Orb.png' style='position:absolute; display:none; left:10000px; top:0px; width:"+(2*Orbsize)+"px; height:"+(2*Orbsize)+"px;'>");
 this.is=b.style;
  this.move=moveOrb;
  document.getElementById("container").appendChild(b);
 this.is.display='block';
 this.is.id=ID;
}
 
Code:
 
function moveOrb(x,y,z){
 k=(Zeye-Zscreen)/(Zeye-z);
 os=(Orbsize*k);
 x=x-os;
 y=y-os;
 var OS=os*2;
  this.is.width=OS;
  this.is.height=OS;
  this.is.left=x;
  this.is.top=y;
  this.is.zIndex=z;
 //if(document.getElementById('message').style.top>0)document.getElementById('message').style.top=document.getElementById('message').style.top-1;
}
here is the calling code: Orb[a].move(px[a],py[a],pz[a]); Orb[a+50].move(px[a],(px[a]+offsetx),pz[a]); Orb[a+100].move(px[a],(py[a]+offsety),pz[a]);
When I declare Orb as an Array, no problem...
When I declare Orb as an Object, moveOrb() throws the error "Invalid argument"... What's up?

Am I correct in my understanding that Array is a predefined Object and is really not much different than a defined argument?
__________________
Sleeping Troll, EMUSE, Mind Expansion...Truly serendipity!
Sleeping Troll is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 05-18-2009, 08:45 PM Re: this.is making me nuts!
mgraphic's Avatar
Truth Seeker

Latest Blog Post:
JAMISONTUNES
Posts: 2,898
Name: Keith Marshall
Location: Connecticut
Trades: 0
No - In my understanding an array is much different than an object. An array is numerically indexed and an object is namedspaced.
__________________

<mgraphic /> - I don't have a solution but I admire the problem.
mgraphic is offline
Reply With Quote
View Public Profile
 
Old 05-18-2009, 09:05 PM Re: this.is making me nuts!
Sleeping Troll's Avatar
Ultra Talker

Posts: 351
Name: Butch Begy
Trades: 0
Hmm, good point.
__________________
Sleeping Troll, EMUSE, Mind Expansion...Truly serendipity!
Sleeping Troll is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to this.is making me nuts!
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.11445 seconds with 12 queries