I just did a quick port to processing, important to notice that these classes are “as is”, but still, the speed of Java compared to Flash is… well lets just say the gap isn’t quite gone yet
EDIT: forgot some int/float math that made the tentacles look bulky… better now. Example and code here:
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 );