Random Walk

Actionscript:
  1. var xp:Number=Math.random() * stage.stageWidth;
  2. var yp:Number=Math.random() * stage.stageHeight;
  3. graphics.lineStyle(0,0x000000);
  4. graphics.moveTo(xp, yp);
  5. addEventListener(Event.ENTER_FRAME, onLoop);
  6. function onLoop(evt:Event):void {
  7.     xp+=Math.random()*10-5;
  8.     yp+=Math.random()*10-5;
  9.     graphics.lineTo(xp, yp);
  10. }

Nothing special here, but its good to know that this technique has a name... and that it's NOT Brownian Motion... more here.

This entry was posted in Graphics, motion and tagged , , . Bookmark the permalink. Post a comment or leave a trackback: Trackback URL.

Post a Comment

Your email is never published nor shared. Required fields are marked *

*
*