Gaming Your Way

May contain nuts.

Ye olde formular plotted in 3d trick

So after Squize was boring us with that grid, I thought it's time to give AS3 a go (finally).

While diving into the "new" AS version I also tried a new editor, I use(d) se|py for AS2, but felt the need to try something new editor wise, too.

I had a look at SharpStyle Neutron, a coding plugin for Visual Studio 2005 (imho one of the best coding environments), but as it's AS2 only (the current beta is able to handle AS3 it seems) so while it's great for AS2 it didn't help me on my current task ...

Another Editor I wanted to give a go was FlashDevelop. I instantly fell in love with the current 3.0.0 beta build. It feels like Visual Studio, it's fast and has some niffty, helpfull features.

So I did what I always do in a new language, I coded a 3d formular plotter, the idea reaches back to the good old c64 days, though, it took a whole night to render a way smaler version.

Anyway this is what I came up with during my first 2 hours of AS3:
plotter.swf (1,31 KB)

It's not that impressive, but it's fast (just used an onEnterFrame to show the plotting).


A bit more of the same

Well I carried on working on the GWars effect last night, and discovered quite a few things.

The example from yesterday used a raster line plotter, but I tried it with the Flash drawing API ( Which uses Flash's vector plotter ) and it crapped all over it in terms of speed. I was surprised but I guess it's 'cause the dAPI works on a "hardware" level.

Next up was to look at Geometry Wars itself, where I realised that the grid was made up of a load of dots rather than lines. Back to the code, I used the dashTo prototype ( An example of that can be seen here ) and got a nasty drop in speed. No shock there really. Then it dawned on me that the raster line drawer could be kinda handy here, after all it's just a loop and some setPixels, if we're skipping pixels to make a dotted line then it'll reduce the length of the loop.

Sweet, ran a lot quicker.

Next up was a bit of a lucky one. I had a bitmap which I copied the grid to every couple of frames and ran a ColorMatrixFilter on it to fade it down ( By reducing the alpha every frame ), and where I was putting a surround on the screen and positioning things I screwed up the alignment of this bitmap, so I could see the lines slightly offset. It didn't take long to align it so it was offset by half a grid position on the x/y, hey presto, twice as many lines and for no more hit than it was running at anyway.

Time to drop a player sprite in there ( My very first as3 one, I imagine there will be more ). I really liked the control system in neon2, where holding ctrl down stopped the player ship so you could just rotate and shoot, and as3 just gave it to me for free.
When using a MouseEvent.MOUSE_DOWN event listener, the event which is called has an arg passed to it. This arg has all types of interesting goodies in it, one of which is a boolean ctrlKey flag. So adding the keyboard control I wanted took about 3 lines, and from a cpu point of view it's a freebie ( Ok, at the hardware level Flash is scanning the key, but it does anyway on a MOUSE_DOWN event so it's not like I'm polling the keys seperately ).

Want to see it ? Yeah you do.

GWars_v2.swf (37.69 KB)


May look slightly familiar

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'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);

//Test for a straight vertical line
          for ( i = 1 ; i <= dy ; i++ ){
            y += yinc;
          for ( i = 1 ; i <= dx ; i++ ){
              x += xinc ;
    if ( dx > dy ){
        cumul = dx >> 1;
          for ( i = 1 ; i <= dx ; i++ ){
            x += xinc;
            cumul += dy;
            if (cumul >= dx){
                  cumul -= dx;
                  y += yinc;
        cumul = dy >> 1;
          for ( i = 1 ; i <= dy ; i++ ){
            y += yinc;
            cumul += dx;
            if ( cumul >= dy ){
                  cumul -= dy;
                  x += xinc ;
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)


Finally got it out of my system

This is it, the last demo effect I'm going to be doing in as3. There are of course more I'd like to do ( Using a plasma as a texture would be a neat one that springs to mind ) but I guess I should be more productive in an actual game kind of way with my free time, rather than pointless eye candy.

Anyway, enjoy yet another cube variation.

DotVectors.swf (32.28 KB)


35 and still playing with demo effects

Still trying to get my head around as3, it's a saucy little minx alright.

Anyway, he's yet another old school demo effect, and another one I never managed to get working on the Amiga at the time ( Flash just seems to be an outlet for my past failures as a coder ).

Plasma.swf (5.47 KB)

Guess a bit of texture mapping should be next to keep with this theme.

( For a lot more demo style eye-candy check the experiments cat., and to see them all shoved together and wrapped up with plenty of love, check out 651 )


AS3... Not exactly the easy way forward

I've had a bit of down time since Friday, so I thought I should finally look into AS3.

I've heard lot's of comments from fellow game devs. That it's a steep learning curve. Being kinda cock sure I thought "It can't be that bad".

Oh silly silly me.

I remember hating AS2 when I crossed over to that late last year, and loving it now, so I know that AS3 is just going to be the same. That nasty month or two of "If I could do this in AS2 it'd have been done 3 hours ago", and that feeling of going from being pretty good at something to absolute lamer. Never nice.

Anyway the fruits of my labour are below. It's just a re-working of my infinite bobs effect I did a little time ago ( In as1. In an hour ). At least I've managed to convert my fps counter ( Although ensuring it stays on top of all the other mcs / sprites / displayObjects / whatever the hell they're called now, is still a bit beyond me ).
No preloader, as that seems to be a can of worms, but it's less than 13k so it's not an issue with this. Also it's not really a clever clever AS3 speed test, the whole point of the original code was to show you can still do funky things in as1 ( It was a slight backlash against what seemed like everyone at that time acting like as3 was the second coming ).

InfiniteBobs.swf (12.18 KB)