Polygon Collision and the Separating Axis Theorem in ActionScript
Jun/105
I’ve been spending quite a bit of time on my latest game project which, like many other games, requires collision detection. Knowing that using brute force for broad-phase detection wasn’t an option, I implemented a spatial hash to partition the world’s game objects into manageable groups. At this point, I was ready to tackle the narrow-phase portion and immediately sought to use a form of pixel-perfect collision I’ve grown to understand and use fairly well. Unfortunately, this type of detection is inappropriate for a lot of things and an avatar moving along a tile-based set is one of them. It can be fairly costly and is better suited for boolean-based tests. After trying to force this algorithm to do something it shouldn’t, I finally settled down and visited a form of collision I had known about for a while but had not the need to implement…until now.
Vim Omnicompletion for ActionScript 3
Dec/081
Shortly before we received Flex IDE licenses at work, I was in the process of writing an ActionScript 3 omnicompletion plug-in for vim. The ‘flash’ package is covered for the most part while ‘mx’, ‘flashx’ and ‘air’ are still lacking.
Anyway, it’s not serving the community sitting around my hard drive so I went ahead and pushed it up to the vim script repository.
http://www.vim.org/scripts/script.php?script_id=2478
Hopefully, it will make someone happy.
State Machines in ActionScript
Dec/080
I love simple solutions to complex things. Squize’s post over at Gaming Your Way on State Machines in ActionScript explains an issue game developers often face that is elegantly handled with function pointers.
It’s been months since my last post (and coincidentally changing jobs) but I’d recently dusted off a grid-less rendering engine for 2d games and was slightly disgusted with it core. It’s really not that bad. It works but the main loop gets a wee-bit lengthy and burns up cycles evaluating items that could possible be out of context at any given moment.
Using function pointers to create a state machine wraps this up nicely. Cheers, Squize!
Flex Components: MXML vs. ActionScript
Jun/081
One question that has constantly nagged me during my conversion from Flash to Flex development is, “Do I write this thingamajig in MXML or ActionScript?” The question is usually answered by the type of component that’s being written. If it’s a visual component, I’ll write MXML otherwise, I’ll write the whole thing in ActionScript.
C/C++ to ActionScript Cross-Compiler
Feb/080
Last year, at MAX 2007 Scott Peterson showed everyone a demo of various C apps running in the Flash Player. It was pretty radical stuff. I recall seeing the demo and feeling absolutely speechless.
Well, I totally forgot about this (too good to be true?) until today, when Ted Patrick announced that indeed, development is still moving forward in this area.
I’ve been chewing on the thought of creating P2P clients in AIR but couldn’t figure out an elegant approach to packaging a client module (written in ActionScript) and a server module (written in C/C++, Java or Python) in a single AIR installer…
Could this be it?
ActionScript 3 SGS Client Template
Feb/080
I’ve been playing with SGS lately and must admit, I freaking love it.
It’s free, GPL’d, has excellent documentation and just plain works. On top of all that, there’s even a full-fledged ActionScript 3 Client API available!
While working through the tutorials I found myself writing more than one flash client and decided I’d be better off distilling them down to a single template. I think it’s a decent starting point for those “Hello World” demos and could potentially become the base for a full-blown, multi-user client application.
You can download the files, here.
Please let me know if you’re working on a Flash client for an SGS application. I’d love to hear about it!
Bitmap Collison Detection with ActionScript 3
Sep/071
I finally got around to converting Grant Skinner’s collision detection algorithm to ActionScript 3. This version primarily takes advantage of the latest library class/method additions.
For anyone familiar with Grant’s implementation, you’ll notice the method signature is similar.
To determine whether or not the bitmap data values of two display objects are “colliding”, you simply call:
var x:Rectangle = Collision.collisionTest(myObj, yourObj);
Alternatively, you may also pass a third argument representing the alpha tolerance which in turn gets passed to the alphaTolerance argument of the ColorTransform constructor.
var x:Rectangle = Collision.collisionTest(myObj, yourObj, alphaTol);
You can see an example, here or download the Class definition, here.
