Wednesday, April 30, 2008

Particles Effects with Gravity







That's it, try to click and hover your cursor above the platform! quite kewel eh;p, sedikit contoh bagaimana sebuah rumus fisika dan matematika diaplikasikan ke dalam flash, and here's the actionscript:

var n:Number = 30;
var d:Number = 150;
var s:Number = .003;
var c:Number;
Mouse.hide();
attractor.mass = 2;
init();
function init():Void {
     for (var i:Number = 0; i  
       var particle:MovieClip = attachMovie("particle", "p"+i, i);
         particle._x = Math.random()*Stage.width;
         particle._y = Math.random()*Stage.height;
         particle.vx = Math.random()*3-2;
         particle.vy = Math.random()*3-2;
         particle._xscale = particle._yscale=20+Math.random()*100;
         particle.mass = particle._xscale/100;
      }
}
function onEnterFrame():Void {
attractor._x = _xmouse;
attractor._y = _ymouse;
for (var i:Number = 0; i var particle:MovieClip = this["p"+i];
particle._x += particle.vx;
particle._y += particle.vy;
............there there i'm not gonna write it down all for you,
pusing!!;p

kalo mau silahkan ubek2 di masputih.com, it belongs to Indonesian of course:) and yes he encoded the script himself

.:abdinusa:.

2 comments:

perempuan said...

Wah, keren abis! Hebat banget bisa coding begituan.

Pasha said...

keren.....just goes to show kids that math is useful everywhere! :D