Archive for September, 2007

Feeding the Back

well, I have made a few more (largely aesthetic) changes to the game thanks to the feedback provided by the loverly folks over at the Ars Technica forums at this thread (by the by, if you don’t subscribe to their various RSS feeds. DO SO! it’s consistently good stuff in my humble opinion)

Essentially, I reintroduced some higher res sprites, that I had previously down res-ed in my quest for performance, turned out I was optimizing the wrong bottleneck. So that mistake has been repaired.

Also, the embed size of the flash movie at the game page has been restored to it’s full size 800×640 glory. I am assuming that the type of folks who will be playing this will have monitor resolutions larger than 1024×768 so as to accommodate the larger size, if not, comment and I will see what I can do.

I got rid of the Chiller font in the in game HUD items, as it was not terribly readable 🙁 I don’t know why I had clung to that choice until this point…maybe just amateur petulance. Live and learn.

Also, I changed the selection mechanic for Defenders so that it auto-queues the move command when selecting units. Subsequent move command must be queued up normally, or one can re-click the unit to re-select it and re-queue the move command. Confused? Just try it out and it will make sense. This was the compromise brought about by the fact that Flash monopolizes the right click in it’s player context menu (right click normally being used to issue command in a RTS) and the left click (typically used to de-select all units and do camera movement or building placement in RTS) is the only way to interact mouse-click-wise. So I had to go with this less than perfect compromise. But it is an improvement, so life goes on with another note made in the ‘Idiosyncrasies of Flash Game Development’ list I keep in my head.

That sums it up for now. Now Go Play


New version here.

I’ve managed to once more squeeze better performance out of the engine. I’ve also retooled the debris placement mechanic, so it should be alot faster, more fluid and feel like ‘painting’ more than meticulous insertions.

The optimizations will no doubt continue, as I can’t seem to stop puttering with the thing, but it’s at a point where it performs pretty well all things considered.

This has been a wonderful learning experience and has illuminated a lot of tricks for optimizing AS3. I’ll share my specific thoughts in detail about this in a future post, but for now, I offer bullet pointed goodness:

  • ‘cacheAsBitmap = true’ is your friend for speeding rendering on largely static objects. (this is responsible for the most recent performance increase) A caveat to be aware of is that this property can SLOW DOWN render performance if the object in question is rotated or resized frequently.
  • onMouseMove is an evil, evil event in a highly interactive, performance sensitive app, as it can, in effect, clog the event queue and delay the onEnterFrame event from firing. It’s best to process mouse movement events within the onEnterFrame event, this keeps your main loop running smoothly.
  • Cloning multiple instances of a Bitmap by creating a master embedded copy (say as a static member of a Zombie class called ‘masterIcon’ for example) and creating new instances using the bitmapData of that static object as an argument to the Bitmap constructor saves hugely on memory allocation, and anecdotally is faster to render. for example:

‘this._zombieIcon = new Bitmap(masterIcon.bitmapData);’

  • The mechanics of writing a preloader that is NOT just a separate SWF loading in your desired SWF is a pain in the booty. In effect it is simple to accomplish once you know the super secret method, but that method is not easy to discover, as it does not seem to be represented in the official documentation. (I’ll detail said method in the next post….how’s that for a cliff hanger?!)
  • alpha values not equal to 1.0 or 0.0 are not your friend if you have many small objects in the display list with said values.
  • I can’t wait for flex builder 3 to be finished, the profiling tool that half functions in the beta version has been INVALUABLE in hunting down bottlenecks for optimization. If you don’t KNOW where your bottlenecks truly are, trying to optimize based on educated guessing is an exercise in frustration to say the least.

That wraps it up for the moment, now Go Play!

-Joe out.