Wednesday, 6 June 2007

A complex engine

I started to learn Actionscript in January, having messed around in Flash to make the odd banner advert or fading alpha image from time to time and have really got to grips with AS2. I'm hoping to move ahead with AS3 at some point soon but as my AS2 compiles under Flash CS3's AS3 mode anyhow, there is no rush at this point.

Anyway I'm digressing somewhat. I was recently wanting to create an online story based roleplaying game and so converted my conversation engine from Lingo (Director) to Actionscript (Flash) as a nice class based little bit of kit. Flash has problems reading files that Director doesn't, however, so I figured I would hold the conversation engine data in a database online and expose it to Flash through an ASP file that it's LoadVars command could communicate with. This worked a treat and I was able to convert my code, create the database and admin forms, in just a few days.

I will be using this code within Freeform Space to generate menus and conversations. The aim is to get some missions in there and have some form of negotiating (like the original Freeform, but more complex, like in Frontier), so this wasn't by any means wasted effort even though I've switched my focus to totally different game idea.

This backend technology is used throughout the existing Freeform Space Flash engine, even the online demo uses it. The FSF engine itself contains Actionscript coding, a vapour trail symbol and a laser shot symbol - everything else is external. The engine queries a database through an ASP page to get a list of everything it needs to import then begins to download each item in the list. You can see it doing this in the demo, the loading sequence begins with a database query and then it proceeds to inform you of each item it is downloading.

The only exception to this is the sound effect, which so far is loaded in as required and not before hand. I may try experimenting with putting it into the database as a download list to get rid of the slight lag the first time the lasers are fired, but its come about because to my knowledge you cannot import a sound file and just play it through code without manually going in through Flash and ticking an "export for Actionscript" box which obviously cannot be done if the sound is not yet inside the movie and is loaded at run time.

I have some other limitations from Flash to content with too. It would seem that you cannot duplicate a movie clip that is downloaded at run time. This could be problematic later on. If I need ten of the same ship, will I have to download the same graphic ten times? Presumably the browser cache will really help me out here if this is the case.

The engine is already quite complex and there is a lot more to do yet. Time will tell if I have to change my approach, but for now, I'll keep trying to achieve the Holy Grail of seperating code from content.

0 comments: