## May look slightly familiar

It's still not a 100% right, and I think to get much more speed out of it I'm going to have to really rethink it, but it does look pretty cool.

A lot of the actual clever stuff which is beyond me was taken for a example at the always astounding liquid journey site. I also used bytearray.org's raster based line plotter, which I tweaked slightly to try and get a few more ms out of it ( Code for the tweak is here )

public static function quickLine(bmp:BitmapData,x0:int,y0:int,x1:int,y1:int,c:Number):void{And that's about it really. I'm hoping to play with this some more next time I get chance and hopefully make a homage to a certain popular shoot'em up.

var i:int;

var xinc:int;

var yinc:int;

var cumul:int;

var x:int = x0;

var y:int = y0;

var dx:int= x1 - x0;

var dy:int= y1 - y0;

xinc = ( dx > 0 ) ? 1 : -1;

yinc = ( dy > 0 ) ? 1 : -1;

dx = (dx ^ (dx >> 31)) - (dx >> 31); //Math.abs

dy = (dy ^ (dy >> 31)) - (dy >> 31);

bmp.setPixel32(x,y,c);

//Test for a straight vertical line

if(dx==0){

for ( i = 1 ; i <= dy ; i++ ){

y += yinc;

bmp.setPixel32(x,y,c);

}

return;

}

if(dy==0){

for ( i = 1 ; i <= dx ; i++ ){

x += xinc ;

bmp.setPixel32(x,y,c);

}

return;

}

if ( dx > dy ){

cumul = dx >> 1;

for ( i = 1 ; i <= dx ; i++ ){

x += xinc;

cumul += dy;

if (cumul >= dx){

cumul -= dx;

y += yinc;

}

bmp.setPixel32(x,y,c);

}

}else{

cumul = dy >> 1;

for ( i = 1 ; i <= dy ; i++ ){

y += yinc;

cumul += dx;

if ( cumul >= dy ){

cumul -= dy;

x += xinc ;

}

bmp.setPixel32(x,y,c);

}

}

}

GWars.swf (7 KB)

Squize.

## tomsamson

8/16/2007 1:59:32 PM |looks nice though you shouldn´t use setPixel32 if not absolutely mandatory since its slow.

## Squize

8/17/2007 9:36:00 PM |Yep true blue, but then it means that the bitmap you're plotting to has to be the bottom most image in the display, so you can't have a background image.

There's a new faster version that I posted at FK, which I'll post up here when I get a minute.