Inspired by
this thread at FK games I decided a nice little break from mansion would be in order and started playing with a geometry wars style grid.
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{
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);
}
}
}
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.
GWars.swf (7 KB)Squize.