Brian Chia
       
 
categories
actionscript
actionscript 1.0
actionscript 2.0
misc
 
processing
 
links
brian chia
kelvin zhao
ronald leong
 
 
Brownian Motion v01
 
There a limits to how many particles i can created to collide with the blue ball. I tried to increase the amount to 150 and higher and flash started to lag. Thus, i keep my particles number to 100 as my main purpose is to illustrate how brownian motion works.

The code for this sample was very similar to Momentum v03, thus i would only be showing the new codes that i add in. For coding on multi collision and conversation of momentum, please refer to the Momentum post.


import Vector;

// inital ball0 (particle suspended) properties
ball0.m=2;
ball0.r=ball0._width/2;
ball0.v=new Vector(0,0)

// create movieclip to store lines drawing for brownian motion
createEmptyMovieClip("line_mc",getNextHighestDepth());
line_mc.lineStyle(0,0xFF0000,100,true,"none","none","miter",1);
line_mc.moveTo(ball0._x, ball0._y);

// create num of balls
var numBalls:Number=100;
for(var i:Number=1;i<numBalls;i++){

// declare balls properties

}

this.onEnterFrame=function():Void{

// draw brownian motion
line_mc.lineTo(ball0._x, ball0._y);

// balls movement and check collision

}



suggestion