Flash isometric engine

At the start of this year I began work on an isometric engine for a Flash game I was developing at work. Now there are heap of books that deal with the logic of game dev in Flash, and to get me started, I went out and bought Flash game dev demystified.

Now, because I was specifically interested in isometric engines, and knowing a fair bit about Flash already, I thought that reading the whole book wouldn’t really be a worthwhile experience… but I was wrong. It turned out to be a great read, and even though in my engine I didn’t really use much of the new knowledge I gained, it certainly helped round out some missing information – in particular basic physics.

Another good source of information was the web, most notably Kirupa, a site which continues to be a great source of information and techniques, and includes posts from the endlessly giving Senocular. There were more, but I can’t lay my hands on the addresses at the moment. The important thing to note though, was that both the books and the web had similar and differring ways to approach the same problem – which is a truth for EVERYTHING in Flash. And by exposing myself to them all, I was able to understand enough to get me a long way into my own attempt at an isometric engine.

So, why the rant? Well, I wanted to share with you some things that I’ve learnt from the experience, and for what it’s worth, here they are :

NB : The isometric engine I worked on was for Flash player 7. If you were unaware, Flash player 8 and above do many things MUCH MUCH better than 7, and this information is probably irrelevant for the newer Flash players – but very relevant if you are still making content for Flash player 7.

1. Optimizing code performance at runtime AND at compilation stage.
I was fortunate enough to come across Odd Hammer which outlines various techniques to make your Flash movie run better when exported from various Flash IDEs. Ill let you read al the good stuff there… its well worth it. What I was unaware of was that writing things in different ways at author time could effect quite dramatically performance at runtime.

2. Extensibility
I stuck with XML to feed my engine. It began using a similar format that other engines used, but as I wanted to add more interesting interactions, I found that I had to extend it. But thats the beauty of XML. On that same token, I also load all my tile artwork in at runtime, so that I can have various levels each with their own look and feel, and not affect the base file size of my SWF.

3. Limitations
The biggest limitation to the approach that I took concerned controlling the speed of the action. Because I introduced depth (that is, stepping up or down stairs or a platform) it became impossible to control the speed of character movement in the isometric world more than regular speed and half speed.

This was because if I moved a character in any direction at less than half a tile’s size, at some stage he would be slightly over the next tile. Normally, not a problem. But because in my world that next tile could also be a step up or down and in any direction, this meant I had to manage the swapDepth of the character in relation to each individual tile, rather than just a single movieclip containing the floor.

4. Artwork and workarounds
The engine I made was designed to have many levels each with different artwork. One thing I tried to do was make producing each level as easy as possible. I explored making a level maker, but time didnt allow. Also, I thought that it would be just as much work to make it as to make the engine. So, what I wanted was for the design of the objects that live in my world not be too difficult. IE, I didnt want the designer to have to cut each piece of artwork up to the size of the tiles and then have me recreate it
in Flash. So instead, I made a workaround that allowed for an object to be placed in the world, via an XML description of where it lived, and what tiles around it would be unwalkable. Flash did all the rest.

5. Link
Here is the engine in all its glory. Im pretty happy with it – i know it could be improved greatly, but I think for what I wanted from this project, it is a good result. I cant show the code for the project im afraid, seeing as it is a commercial project, but it follows the same ideas as outlined in the links above, with some small differences.

6. Future
There are examples of Mario-style 3D from many years ago, like this one, that make my little iso world seem old hat. And now, there is soo much more chances of developing cool and interesting 3D things for Flash, specifically because Flash 8 has added bitmap caching and blitting et al, that improve runtime performance exponentially. (some links : here, and here)

All this means more chances for us Flash developers to do cool things. It’s just a matter of the right output for the right project.

  • Scott Davies

    Hi Dan,

    Nice work on the game its brilliant! Is it possible to get any weblinks that helped you in your development for this? And any other tips and tricks?
    Thanks
    Scott :D

  • dan

    Hey Scott, thanks for the cudos!

    The main links I looked at are in the post, but the real mind leap came from Flash Game dev demystified. It comes with a CD of examples, plus talks through some of the issues to overcome.

    I started by following on with their tutorials, but then soon realised that their approach wouldn’t be fast enough, and wouldn’t afford me some of the things I was looking for. Certainly there is a hell of a lot more that could be done to improve this engine.

    Also, I found that the basic schemas for describing worlds in XML weren’t strong enough (you can see some examples at Kirupa.com – just look for isometric). Id be happy to take a look at anything you’ve got and make suggestions…