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

Simulation of the movement of gravitons and their imaginar part. :D
Get Adobe Flash player
by teeandy 25 Aug 2012
    Embed






 
 
 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=1;
        public var sizeOf:Number=5;            // 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=40;    // Amount of gravitons and imaginaer Unions
        public var maxVelocity:int=13;    // beginning speed 
        
       
        function Main():void {

            onePart = [];
            var verrynewboxx:int = Math.random() * 400;    // hm
            var verrynewboxy:int = Math.random() * 400;
          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++){
       
 
                verrynewx = Math.random() * 400;    // hm
               verrynewy = Math.random() * 400;
                // Schuim the same? no :D
   // 
               // var newboxx:int = Math.random() % 24;    // hm
              //  var newboxy:int = Math.random() % 24;
                verryv = Math.random() * maxVelocity;    // hm
                verrya = Math.random() * 6;    // 2*pi
                          
                          
                newbie = new reDbul( verrynewx, verrynewy, verryv, verrya, verrynewboxx, verrynewboxy);
     
               
                onePart.push(newbie);
            
                array++;
      
           }                 
  

//                onePart[ji-1].show(graphics, sizeOf, sizeImag);//Painting






       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++){
   //      graphics.clear();
     
    //            onePart[iss].show(graphics, diffColor, sizeOf, sizeImag);//Painting
             onePart[iss].move();            // set new Realpossition
      //    setImag( iss );             // set the position of the imaginaer part
          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);//Painting
         
    }
       reMix();
     plopi();

}     
/*
        var color:int = Math.random()*0xFF33CC;
         graphics.beginFill(color, 85); //?? color,85);
        graphics.drawCircle(200, 200, sizeImag);
        graphics.endFill();
 */   
        }
        
        
        
        private 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 < 200 ) {
            bootSystem= !bootSystem;  
            }
      // bootSystem= !bootSystem;        // ;
   
        }
            
            
        private function onMouseDoubleClick(e:MouseEvent):void
        {
            realImag = !realImag;
            for(var i:int=0; i<onePart.length; i++){
                onePart[i].realImag = realImag;
            }
        }
        

        public function setImag ( inDex:int, i:int, diff:int ):void {
             
             var helpx:int;
             var helpy:int;
             var helpd:int;
             var helpa:int;

        if ( diff > 0.001 ){
 
 
             
             helpy = onePart[i].posY - onePart[inDex].posY;
               helpx = onePart[inDex].posX - onePart[inDex].posX;
             helpd =Math.sqrt(helpx*helpx + helpy*helpy);
             helpa = Math.asin(helpd / helpy);
             
             //:)
                    if( onePart[inDex].a > helpa  ){
                        onePart[inDex].a += 8/10/imagUniverse/20/diff*sizeImag;//percentImag*sizeImag;
                    }else{
                        onePart[inDex].a  -= 8/10/imagUniverse/20/diff*sizeImag;//percentImag*sizeImag;
                   }
        
        //:)
                     if( onePart[inDex].a- 1.5 > helpa  ){
    helpd = sizeImag*8/10/imagUniverse/diff/100 ;
            onePart[inDex].v = onePart[inDex].v + helpd;
                    }else{
    helpd = sizeImag*8/10/imagUniverse/diff/100 ;
            onePart[inDex].v = onePart[inDex].v - helpd;
                   }
                   if( onePart[inDex].a+ 1.5 > helpa  ){
    helpd = sizeImag*8/10/imagUniverse/diff/100 ;
            onePart[inDex].v = onePart[inDex].v - helpd;
                    }else{
    helpd = sizeImag*8/10/imagUniverse/diff/100 ;
            onePart[inDex].v = onePart[inDex].v + helpd;
                   }
    
        }                  // 0.8 as percentImag and       /100 and /20 for visualisation
        }


        
        
        public function distance ( inDex:int, i:int ):int {
            
            // sqrt a2 + b2
            // a = i.x minus inDex.x 
            // b = i.y minus inDex.y
            
            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;
 
 //:)
 return gUniverse*8/10*sizeOf*4000/diff/diff/diff;


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

        

        public function makeGravityArc ( inDex:int, i:int, diff:int ):int {
             
             // Mass :D, there are only gravitons
             // addition of inDex.a cause to make two vectors

             var nullstelle:int;
          //   nullstelle = onePart[i].posY - onePart[inDex].posY ;
 //   ????           return onePart[inDex].a;
       //     }
 //     nullstelle = ( onePart[i].a + onePart[inDex].a ) /2;
       
  //easy one     
   //    nullstelle = ( onePart[i].a*diff + onePart[inDex].a*onePart[inDex].v ) /2;
             
    nullstelle = onePart[i].v * Math.sin(onePart[i].a - onePart[inDex].a);         
           nullstelle = nullstelle / ( onePart[inDex].v + onePart[i].v * Math.cos(onePart[i].a - onePart[inDex].a) );
               return   onePart[inDex].a + nullstelle;
            
        }
 
 
 
       public function changeReal ( i:Number, v:int, arc:int ):void {
            
            onePart[i].v = Math.sqrt( ( onePart[i].v + v*Math.cos( arc-onePart[i].a ) ) * ( onePart[i].v + v*Math.cos( arc-onePart[i].a ) )   +    v*v*Math.sin( arc-onePart[i].a)*Math.sin( arc -onePart[i].a ) );
            onePart[i].a = onePart[i].a + v*Math.sin(arc-onePart[i].a) / ( onePart[i].v + v*Math.cos(arc-onePart[i].a ) );

            VelocityBing( i );    // ;
     
       }
       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 = Math.random()*6.28318530718;
      onePart[inDex].posY = Math.random()*400;
      onePart[inDex].posX = Math.random()*400;
}

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 );
                setImag ( inDex, i, diff );
            } // end for


/*             
               // first part for the new values
               //            gravitation 


                diff = Math.sqrt( onePart[inDex].posX * onePart[inDex].posX + onePart[inDex].posY * onePart[inDex].posY - onePart[i].posX * onePart[i].posX - onePart[i].posY * onePart[i].posY );
                    // distance between the summ and the next one
             
                if( diff<=1 ){
                    arcHelp = 1;        // two vectors are next to next
                                        // no addition, no interaction
                                        // they are moving like one                                        // .. is a Merging, Fusion
                                        // Photonbuilding
                                        // .... H2, temperatur, pressure, magnitude..
                                        // ... :D only gravitons :D
                   }
                else {
                   arcHelp = gUniverse/diff/diff;
                   // how much weight have the new graviton in relation to 
                   // distance and the constant g
                   
                   // :D
                   
                }
         
                  arcHelp = arcHelp * onePart[i].v; // is now vector2
                 
                // second part 
                // vectoraddition

                // vector2 from the last round with the for is now vector one 
                    // vector1 summv and beta
                    // vector2 arcHelp and onePart[i].a
                forvar =  arcHelp*Math.sin(onePart[i].a-beta) / ( summv + arcHelp*Math.cos(onePart[i].a-beta ) );
                   // forvar as new result of the arc         
                // vector2 from the last round with the for is now vector one 

                // beta is now the new arc of summv
                // beta with summv are now vector1
                // arcHelp and onePart[i].a is vector2
                summv = Math.sqrt( ( summv + arcHelp*Math.cos( onePart[i].a-beta ) ) * ( summv + arcHelp*Math.cos( onePart[i].a-beta ) )   +    arcHelp*arcHelp*Math.sin( onePart[i].a-beta)*Math.sin( onePart[i].a-beta ) );
                   
                beta = forvar;
                
            }   // end for
            
                // summv is now the second vector v2
                // summv has now all interaction with the right difference 
                // Vector addition between one...inDex... and all other ....summv
       
               // vector1 is onePart[inDex]
               // vector2 is summv and beta
       
            onePart[inDex].v = Math.sqrt( ( onePart[inDex].v + summv*Math.cos( beta-onePart[inDex].a ) ) * ( onePart[inDex].v + summv*Math.cos( beta-onePart[inDex].a ) )   +    summv*summv*Math.sin( beta-onePart[inDex].a)*Math.sin( beta -onePart[inDex].a ) );
            onePart[inDex].a += summv*Math.sin(beta-onePart[inDex]) / ( onePart[inDex].v + summv*Math.cos(beta-onePart[inDex].a ) );
                // :D
                // sorry bout the crossing usage of beta as arc in the formulas
*/
} // end of else
        } // end function


  }    // end class UniverseTest




 } // 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 function reDbul(newyx:int, newyy:int, newyv:int, newya:int, newybx:int, newyby: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;

     }

    public function show (graphic:Graphics, diffColor:int, factorDisplay:Number, factorBox:Number):void
    {
        var Numberx:Number = posX;
        var Numbery:Number = posY;
        
        var color:int = Math.random()*0xFF33CC;
        graphic.beginFill(color, 85);//diffColor, color); //?? color,85);
        graphic.drawCircle(Numberx, Numbery, factorDisplay);
        graphic.endFill();
 //       Numberx = bx;
  //      Numbery = by;
//        graphic.drawRect(Numberx, Numbery, Numberx + factorDisplay*factorBox, Numbery +factorDisplay*factorBox); //:D
    }
    

     public function move():void{
     
         posX += v * Math.cos(a);
         posY += v * Math.sin(a);

     }



    public function bing():void{
        
   
      if(v<0){
          v=  4;//maxvelocity;
         }
      if(a>6){
          a =  a - 6;//maxvelocity;
         }
      if(a<-6){
          a =  a + 6;//maxvelocity;
         }
      if((a<0.0005) && (a>-0.0005)){
          a =  0.006;//maxvelocity;
         }
        
        // :)
        if(posX==oldX || posY==oldY){
            remix++;
        }
        else{
             remix = 0;
        }
             
        oldX=posX;
        oldY=posY;
        
        
        if(posX>380){
            a = 3 - a;
            posX = 360;
        }
        if(posY>380){                // ! upsidedown :D
            a = -1 * a;
            posY = 360;
                      }
        if(posX<10){
            a = 3 - a;
            posX = 20;
       }
        if(posY<10){
            a =  -1 * a;
            posY = 20;
                     }
          /*
           if(a>6.2){
                 a -= 6;
          }
           if(a<-6.2){
                 a += 6;
          }       
          */
          
          
            // the possision of the boxxes :D
        }        // end function bing


    }       // end class reDbul



//}            // end package