Im looking into some of the random walk stuff out there and I stumbled upon www.actionsnippet.com and his RandomWalk experiments, great site by the way, bring coffee.
The thing that was cool about his way of doing it was that he constrains the “walkers” to only move: up, down, left and right. Absolutely no diagonal movement. This produces a strange grid looking pattern.
public class RandomWalk extends Sprite { private var _canvas:BitmapData;
private var _count:int=100;
private var _movers:Vector.<Mover>;
public function RandomWalk() {
var w:Number =512;
var h:Number =512;
scaleX=scaleY =0.25;
_canvas = new BitmapData( w *4, h *4, false, 0x222222 );
addChild( new Bitmap( _canvas ));
_movers = new Vector.<Mover>();
for( var i:int=0; i < _count; i++) {
_movers[ i ]= new Mover( _canvas, w *1.5+ Math.random()* w, h *1.5+ Math.random()* h ); }
addEventListener( Event.ENTER_FRAME, onRun ); }
private function onRun( evt:Event ):void { for(var i:int=0; i < 200; i++) { for(var j:int=0; j < _count; j++) {
_movers[ j ].run(); } } } } }
import flash.display.BitmapData;
class Mover {
public var x:Number;
public var y:Number;
public var velX:Number;
public var velY:Number;
public var speed:Number;
private var _canvas:BitmapData;
private var _color:uint;
public function Mover( canvas:BitmapData, xp:Number, yp:Number ) {
_color = 0xFF6600;//Math.random() * 0xFFFFFF;
_canvas = canvas;
x = xp;
y = yp;
velX =0;
velY =0;
speed=Math.random()*5-2.5; }
public function run():void {
x += velX;
y += velY;
_canvas.setPixel( x, y, _color );
I had been scurrying about over on the Soulwire blog, again, and looking at the tentacles. I did some experiments of
my own, but the tentacles never came out right, not organic enough. I wrote Justin and asked him how he did it and he was really cool about helping out with a code example of how he did that part.
The Soulwire Tentacles was an experiment in PixelBender speed and usability, so he makes it look as if the tentacles are really growing, i.e. starts out small and each “joint” grows as the tentacles grows. Mine is just a look into the random-organic way they grow. Also I was trying to see what kinds of speed I would get by using the Bitmap approach.