In case Flash no longer exists; a copy of this site is included in the Flashpoint archive's "ultimate" collection.

Dead Code Preservation :: Archived AS3 works from wonderfl.net

The Simulation Universe.....Click on left side to randomize, right side to show imaginary part

Gravitons reacting with Gravitons in the size
10 ^ -40 :d

To randomize click on the left side of the screen.
Right to change the view, only real or all.

The small dots are the real part.
The quadrats are the imaginary part.
And the big circles are the reacting field of the imaginary part.

enjoy :d
andyhubers@aol.com
// forked from Andy.Huber's faster :d The Simulation Universe, part II
// forked from teeandy's forked from: forked from: The Simulation Universe, part II
// forked from teeandy's forked from: The Simulation Universe, part II
// forked from teeandy's The Simulation Universe, part II
// forked from teeandy's The Simulation Universe


















// Books about the real and imaginaer part.....
// 









 
 
 package {


    import flash.display.Graphics;
    import flash.display.Sprite;
    import flash.events.Event;
    import flash.events.MouseEvent;
    
    [SWF(width="400", height="410", frameRate="30", backgroundColor="0x000000")]


  
    public class Main extends Sprite
    
     {

        public var runtimeS:Boolean=false;
        public var onePart:Array;
        public var array:int=0;
        public var bootSystem:Boolean = false;    // true to randomice
                                                // false go
        public var flag:Number = 0;    // 0 Beginn
                                        // 1 Randomvalues setting
                                        // 2 Gravity go
        public var diffColor:int= 0xFF33CC;
        
                      
                                        
        public var realImag:Boolean=true;    // true, mit Imaginaeren Teil
                                        // false, only real part
        public var gUniverse:int=4;        // 4
        public var percentImag:int=0.8;
        public var imagUniverse:int=2;
        public var sizeOf:Number=3;            // to get visible on the screen
        public var sizeImag:Number=9;        // return value of a function
        public var gSchuim:int=1;        // can be :D differen
         public var Elements:int=5;    // Amount of gravitons and imaginaer Unions
        public var maxVelocity:int=70;    // beginning speed 
        public var screen:int=40000;
        public var visualScreen:int=400;
       
       public var centerx:Array        // to save the black materie posisions
       public var centery:Array;        // ... normally less
       public var imagReaction:int = 4000;    // screen/visualScreen/sizeImag
       public var showReaction:Boolean=false;       
        public var version:Boolean=true;    // different interpretations
       
        public function Main():void {
        
                centerx = [];
                centery = [];
                  onePart = [];
                  imagReaction = screen/visualScreen*sizeImag*gUniverse/imagUniverse;
            var verrynewboxx:int = Math.random() * screen;    // hm
            var verrynewboxy:int = Math.random() * screen;
          var verrynewx:int;    // hm
                var verrynewy:int;
                // Schuim the same? no :D
   // 
               // var newboxx:int = Math.random() % 24;    // hm
              //  var newboxy:int = Math.random() % 24;
                var verryv:int;    // hm
                var verrya:int;    // 2*pi
                          
                var newbie:reDbul;
     
         
            for(var ji:int=0; ji<Elements; ji++){
               // centerx.push(Math.random() * screen );
                centerx[ji] = (Math.random() * screen );
                array++
            }array=0;
           for(ji=0; ji<Elements; ji++){
                //centery.push(Math.random() * screen );
                centery[ji] = (Math.random() * screen );
                array++
            }array=0;

            
             for(ji=0; ji<Elements; ji++){
       
 
                verrynewx = Math.random() * screen;    // hm
               verrynewy = Math.random() * screen;
                // Schuim the same? no :D
   // 
               // var newboxx:int = Math.random() % 24;    // hm
              //  var newboxy:int = Math.random() % 24;
                verryv = Math.random() * maxVelocity;    // hm0                verrya = Math.random() * Math.PI;    // 2*pi
                verrya = 2*Math.PI * Math.random() ;          
                          
                newbie = new reDbul( verrynewx, verrynewy, verryv, verrya, verrynewboxx, verrynewboxy, maxVelocity, screen, screen/visualScreen );
     
               
                onePart.push(newbie);
            
                array++;
      
           }                 
  


       addEventListener(Event.ENTER_FRAME, plop);    // :D
            stage.addEventListener(MouseEvent.MOUSE_DOWN, onMouseDown);
            stage.addEventListener(MouseEvent.DOUBLE_CLICK, onMouseDoubleClick);
    
     runtimeS = true;
     
     // :)  plopi();
       
        }               
        
       public function plopi( ):void
        {
            runtimeS = false;

   
  
         for(var iss:int=0; iss<Elements; iss++){
              onePart[iss].move();            // set new Realpossition
              setnewVector( iss );    // setting new values interact
              onePart[iss].bing();            // Borderrunners
              if ( onePart[iss].v > maxVelocity /4 ) {
                    onePart[iss].v = onePart[iss].v -  maxVelocity/10;
              }
         }
         runtimeS = true;
     }   
 
 
        public function reMix():void
        {
            var iss:int;

             for( iss =0; iss<Elements && onePart[iss].remix>sizeOf*10; iss++){
                    onePart[iss].remix=0;      
            }
           if(  iss == Elements ) {
                bootSystem= true;  
                plopi ();
                bootSystem= false;  
           }
        }
        
        

        public function plop(e:Event):void
        {
    
        if ( runtimeS ) {
             graphics.clear();
             for(var iss:int=0; iss<Elements; iss++){
                onePart[iss].show(graphics, diffColor, sizeOf, sizeImag, centerx[iss], centery[iss], imagReaction, showReaction );//Painting
            }
            reMix();
            plopi();

        }     
        }
        
        
        
        
        public function onMouseDown(e:MouseEvent):void
        {
            if ( flag == 2 ) {
                flag = 3;
            }
            if ( flag == 1 ) {
                flag = 2;
            }
            if ( flag == 0 ) {
                flag = 1;
            }
            for(var i:int=0; i<onePart.length; i++){
                    onePart[i].rflag = flag;
            }
            if (     e.localX < visualScreen/2 && e.localY < visualScreen/2) {
                    bootSystem= !bootSystem;  
            }
            if (     e.localX < visualScreen/2 && e.localY > visualScreen/2) {
                    version = !version;
            }
            if (     e.localX > visualScreen/2 && e.localY < visualScreen/2 ) {
                    realImag= !realImag;  
                     for(i=0; i<onePart.length; i++){
                        onePart[i].rrealImag = realImag;
                    }
            }
            if (     e.localX > visualScreen/2 && e.localY > visualScreen/2 ) {
                 showReaction = !showReaction;
            }

            
        }
            
            
        public function onMouseDoubleClick(e:MouseEvent):void
        {
            realImag = !realImag;
            for(var i:int=0; i<onePart.length; i++){
                onePart[i].rrealImag = realImag;
            }
        }
        

        public function setImag ( inDex:int, i:int, diff:int ):void
         {
             
             var helpx:int; helpx = onePart[inDex].bx;
             var helpy:int; helpy = onePart[inDex].by;
             var helpd:int=0;
             var helpa:int=0;
             var savex:int; savex = onePart[inDex].bx;
             var savey:int; savey = onePart[inDex].by;
             
          // first x
        var j:int=1;    // count of imag parts around
         for(var i:int=0; i<Elements; i++){
            if ( Math.abs( onePart[inDex].bx - onePart[i].posX) < imagReaction ) {
                 helpx += onePart[i].posX;
                ++j;             
             
             }
             
         }
           helpx = helpx/j;        // so there are more possible
                                    // with /Elements only one
           helpd = helpx;
           centerx[inDex] = helpx;
           
           
         helpx = helpx - onePart[inDex].bx;
         helpx = Math.abs( helpx );   
         if ( helpx < 1 ) { helpx = 0; }else{ helpx = imagReaction/helpx; }
         if (savex > helpd ) 
              {
                  onePart[inDex].bx = savex - helpx;
              }
         else {
                onePart[inDex].bx = savex + helpx; // egg
              }
            
              
            // now y
        j=1;    // count of imag parts around
         for(i=0; i<Elements; i++){
            if ( Math.abs( onePart[inDex].by - onePart[i].posY) < imagReaction ) {
                 helpy += onePart[i].posY;
                ++j;             
             
           }
             
         }
            helpy = helpy/j;        // so there are more possible
                                    // with /Elements only one
           helpd = helpy;
           centery[inDex] = helpy;
           
           
         helpy = helpy - onePart[inDex].by;
         helpy = Math.abs( helpy );   
         if ( helpy < 1 ) { helpy = 0; }else{ helpy = imagReaction/helpy; }
         if (savey > helpd ) 
              {
                  onePart[inDex].by = savey - helpy;
              }
         else {
                onePart[inDex].by = savey + helpy; // egg
              }
              
// style of Interpretation     
        if ( version ) {
         for(i=0; i<Elements; i++){
            helpa = ( onePart[inDex].by - onePart[i].by )*( onePart[inDex].by - onePart[i].by );
            helpd = onePart[inDex].bx - onePart[i].bx;
            helpd = helpd * helpd;
            if ( helpa < sizeImag*sizeImag && helpd < sizeImag*sizeImag ){
                  var newArc:int= Math.random()*Math.PI;
                
                  onePart[inDex].bx += sizeImag * Math.sin(newArc);
                  onePart[inDex].by += sizeImag * Math.cos(newArc);
            }
           }

         }
         }
         
           
           
        public function distance ( inDex:int, i:int ):int {
            
            // sqrt a2 + b2
            // a = i.x minus inDex.x 
            // b = i.y minus inDex.y
               var xhelp:int;
          var yhelp:int;
     
   // diff       
          xhelp = Math.sqrt(( onePart[inDex].posX - onePart[i].posX ) * ( onePart[inDex].posX - onePart[i].posX ) );
          yhelp = Math.sqrt( ( onePart[inDex].posY -  onePart[i].posY ) * ( onePart[inDex].posY - onePart[i].posY ) );
          return  Math.sqrt ( xhelp*xhelp + yhelp*yhelp );
       
       //     return Math.sqrt( ( onePart[i].posX - onePart[inDex].posX )*( onePart[i].posX - onePart[inDex].posX  )  +   ( onePart[i].posY - onePart[inDex].posY )*(  onePart[i].posY - onePart[inDex].posY )     );
 
         }




        public function makeGravity ( diff:int ):int {
             
             // Mass :D, there are only gravitons
             // * 60 / diff

  /*          if(diff>100){
                diff = 1;
               diffColor = Math.random()*0xFF33CC;
             return 0;
                }      
            return  60/diff;///Math.sqrt(diff); //1 * 1 * 200 / (  diff);
      perfect          return 800/diff/diff;///Math.sqrt(diff); //1 * 1 * 200 / (  diff);
  */
//  return gUniverse*percentImag*250/diff/diff;
//if ( diff < 0.001 ){
 //   return 1;
//}
//final
// return gUniverse*8/10*sizeOf*100/diff/diff;
 
 // 1/diff/diff is the correct one with physical background ;d
 return gUniverse*8/10*sizeOf*diff/diff*screen*100;




  //    return 800/diff/diff;
//  return 50/diff;
   //Math.sqrt ( diff*diff*diff );// / diff;
            
        }
        
        

        public function makeGravityArc ( inDex:int, i:int, diff:int ):int {
             
            var nullstelle:int;
        var newa:int;    // arc of the gravity
             var xhelp:int;
          var yhelp:int;
     
   // diff       
          xhelp = Math.sqrt(( onePart[inDex].posX - onePart[i].posX ) * ( onePart[inDex].posX - onePart[i].posX ) );
          yhelp = Math.sqrt( ( onePart[inDex].posY -  onePart[i].posY ) * ( onePart[inDex].posY - onePart[i].posY ) );
         
              
  //I           
   if ( ( onePart[i].posX > onePart[inDex].posX ) && ( onePart[i].posY > onePart[inDex].posY ) ){
                    newa = -1 * Math.asin( yhelp / diff );
                }
    //II        
       if ( ( onePart[i].posX > onePart[inDex].posX ) && ( onePart[i].posY < onePart[inDex].posY ) ){
                    newa =  Math.asin( yhelp / diff );
                }
 //IV          
    if ( ( onePart[i].posX < onePart[inDex].posX ) && ( onePart[i].posY < onePart[inDex].posY ) ){
                    newa =  2*Math.PI - Math.PI/2 - Math.asin( xhelp / diff );
                }
  //III        
       if ( ( onePart[i].posX < onePart[inDex].posX ) && ( onePart[i].posY > onePart[inDex].posY ) ){
                    newa = Math.PI/2 + Math.asin( xhelp / diff );
                }
                
 //V
 // same position     
        if ( ( onePart[i].posX == onePart[inDex].posX ) && ( onePart[i].posY == onePart[inDex].posY ) ){
                    newa = onePart[inDex].a; // :d
                }
      return newa;
               
     //    nullstelle = Math.sqrt ( (  onePart[i].v*onePart[i].v + onePart[inDex].v*onePart[inDex].v)  / 2 );
      //   return ( ( nullstelle *  onePart[i].a )+  ( nullstelle * onePart[inDex].a) ) / nullstelle;
            
            
            
        }
 
 
 
       public function changeReal ( inDex:Number, v:int, arc:int ):void {
      
         var help:int;    // helper for the new v value
     
      
          help =  onePart[inDex].v ;
     //      onePart[inDex].v = Math.sqrt ( help * help + v * v );
      //     onePart[inDex].a = arc;
           
                 
            onePart[inDex].v = Math.sqrt( ( onePart[inDex].v + v*Math.cos( arc-onePart[inDex].a ) ) * ( onePart[inDex].v + v*Math.cos( arc-onePart[inDex].a ) )   +    v*v*Math.sin( arc-onePart[inDex].a)*Math.sin( arc -onePart[inDex].a ) );
           onePart[inDex].a = onePart[inDex].a + v*Math.sin(arc-onePart[inDex].a) / ( onePart[inDex].v + v*Math.cos(arc-onePart[inDex].a ) );

            VelocityBing( inDex );    // ;
     
       }
       public function VelocityBing ( i:Number ):void {

        if( onePart[i].v > maxVelocity ){
            onePart[i].v = maxVelocity;
        }
       }
        
         
         
        public function setnewVector( inDex:int ):void{
             // one version :D
             // sets new Values of the vector v with arc a of Listentry Number index
             var summv:int=0;
             var arcHelp:int=0;
            var diff:int;
             
if ( bootSystem ){
           onePart[inDex].v =  Math.random() * maxVelocity;  
            
    onePart[inDex].a = 2* Math.random()*Math.PI;
      onePart[inDex].posY = Math.random()*screen;
      onePart[inDex].posX = Math.random()*screen;
    onePart[inDex].bx = Math.random()*screen;
      onePart[inDex].by = Math.random()*screen;
      centerx[inDex] = Math.random()*screen;
      centery[inDex] = Math.random()*screen;
      
}

else {          

             
            for(var i:int=0; i<Elements; i++){ // :D hehe day three

                diff = distance( inDex, i );
                summv = makeGravity ( diff );
                arcHelp = makeGravityArc( inDex, i, summv );
 
                // onePart i has now the a with arcHelp as v
                changeReal ( inDex, summv, arcHelp );
                if ( realImag ) {
                    setImag ( inDex, i, diff );
                }
            } // end for
} // end of else
        } // end function


  }    // end class UniverseTest


 }

 
import flash.display.AVM1Movie; // hmhm
  
    import flash.display.Graphics;

    
     class reDbul {
        
        public var rflag:Number;
        public var rrealImag:Boolean; 
        public var posX:int;
        public var posY:int;
        public var v:int;
        public var a:int;
        public var bx:int;
        public var by:int;
        public var oldX:int;
        public var oldY:int;
        public var remix:int;
        public var maxVelo:int;
        public var myCoolor:int;
       
        public var screenborder:int;
        public var screenF:int;
        
        public function reDbul(newyx:int, newyy:int, newyv:int, newya:int, newybx:int, newyby:int, maxi:int , screenb:int, screenfactor:int ):void {
            rflag = 0;
            rrealImag=true;
            posX = newyx;            
            posY = newyy;
            v = newyv;
            a = newya;
            bx = newybx;
            by = newyby; 
            oldX = posX/2;
            oldY = posY/2; 
            remix=0;
            maxVelo = maxi;
            myCoolor =    Math.random()*0xFF33CC;
      
          screenborder = screenb;
          screenF = screenfactor; //:d

     }
     
     

    public function show (graphic:Graphics, diffColor:int, factorDisplay:Number, factorBox:Number, centerX:int, centerY:int, imagReaction:int, showReactionn:Boolean):void
    {
        var Numberx:Number;
        var Numbery:Number;
  
   
      graphic.beginFill(myCoolor, 0.9);

      if ( rrealImag )
        {
         Numberx = bx; Numbery = by;
          graphic.drawRect(Numberx/screenF, Numbery/screenF, factorBox, factorBox ); //:D
        }   
        
     Numberx = posX; Numbery = posY;
     graphic.drawCircle(Numberx/screenF, Numbery/screenF, factorDisplay);

    if ( showReactionn )
       {
          graphic.beginFill(myCoolor, 0.05);
          graphic.drawCircle(centerX/screenF, centerY/screenF, factorDisplay*imagReaction/screenF);
        }   
     graphic.endFill();
   }    
    
     public function move():void{
     
          oldX =posX;
         oldY = posY;
         posX += v * Math.cos(a);
        posY += v * Math.sin(a);
         
         // visualisation trick
        // v = v/100*80;
    //    a+=0.6;

     }



    public function bing():void{
        
   
      if(v*v<0.001){
          v+=0.1;                // :d Quantenfluktuation PI
                                  // interupts the full simulation
         }
      if(v*v>maxVelo*maxVelo){
          v = v/2;                // :d Quantenfluktuation PI
                                  // interupts the full simulation
         }
      if(a>2*Math.PI){
          a =  a - 2*Math.PI;//maxvelocity;
         }
      if(a<-2*Math.PI){
          a =  a + 2*Math.PI;//maxvelocity;
         }

        if(posX==oldX || posY==oldY){
            remix++;
        }
        else{
             remix = 0;
        }
             
             
        if(posX>screenborder){
            posX = 10;
        }
        if(posY>screenborder){                // ! upsidedown :D
    
            posY = 10;
                      }
        if(posX<=0){
          
            posX = screenborder - 10;
       }
        if(posY<=0){
        
            posY = screenborder - 10;
                     }
       
       
       
        if(bx>screenborder){
            bx = 10;
        }
        if(by>screenborder){                // ! upsidedown imagin :D
    
            by = 10;
                      }
        if(bx<=0){
          
            bx = screenborder - 10;
       }
        if(by<=0){
        
            by = screenborder - 10;
                     }
          
          
            // the possision of the boxxes :D
        }        // end function bing


    }       // end class reDbul


//     }            // end package