This engine was my senior thesis in school, and a hobby before that. It started out with me wondering if I could reimplement RPG Maker XP in Java, using open-source libraries. Turns out I can, and I did enough of that to satisfy me. Java was too slow (or, more appropriately, I didn’t know enough to write it efficiently in Java), so I ported it to C++. The C++ port done, and a variety of scripting languages embedded and removed, I got bored and starting reimplementing it in a variety of languages as a learning tool. I did Python, Ruby, and later C#/XNA.
When I got my first Flash job offer, I decided I needed a portfolio piece, and this engine seemed a good enough choice.
Anyway, as to why this is cool…
This thing is very complex, especially for Flash. It handles two different layering mechanisms simultaneously – one for human convenience and one for CPU convenience. In the editor, you get three layers upon which to “paint” tiles from your tile palette. When you create the palette, you identify which tiles are logically “higher”, in a z-axis sort of way, than the other tiles. For example, the tree pieces have a height of 1, 2, 3, or 4 (depending on which part of the tree we’re talking about), whereas the grass, water, etc. all have heights of 0. You can paint grass and then a tree piece on a higher layer, and everything just works.
Especially complex is the dead tree coming out of the sunken terrain on the east side of the sample map. This situation requires no special instruction to be interpreted correctly by the renderer. Also notice that tile boundaries are interpreted correctly regardless of complex height scenarios.
Animation and fluid tile transitions are pretty cool within this engine as well. The water, the dirt path, and the sunken terrain are actually only three images total – the transition tiles between each of them, based upon how they’re painted, are built dynamically. In fact, the engine goes one step further, and pre-processes every possible tile, dynamic and static, and builds a single huge bitmap in memory, which it then exclusively uses for all its blitting.
This allows the engine to be pretty fast, considering its complexity. Running at full-tilt (max frame rate allowed in Flash) on my machine uses only about 20% of the CPU.
Have a look and a walk around. Arrow keys or WSAD move.
Update November 06: This now uses Flash 10, and all Array objects have been replaced with Vectors. This has not provided any apparent performance increase, but it makes my code look a lot better. :) Update November 07: It now pulls button scripting (which is just movement at this point) from this file on the server, using the custom o2s scripting language.