This time the spores turned into a tree. It is by no means perfect, the branches does not move upwards with the stem as it should, were this a real orange colored scary spore tree.
This was just some “while Im doing nothing, let’s put whatever in the ‘fun’ category” but if anyone would like the code, throw me a comment and I’ll send it off. I is uncommented and messy.
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 );