Flash Scroll Engine: Super Tiles (Part 1)
This is based on Strille's tile based tutorial.
I was quite impressed when I saw his Sonic Demo in action, basically for 2 points:
- Speed
- Massive map.
Both properties were unreachable with the engine I'd used on my previous games Incoming Storm and Fall of 21XX (which aren't based in any tile based mechanism). In order to keep speed, I had to slice the map in multiple secions, showing only one part at once (and usually with no way to return to a previous section). That trick worked well inspired on the NES Mega Man games (I'm guessing they had to do that also for perfomance problems), but I wanted to have huge maps like in Mega Man X. So, with the given documentation, I adapted Strille's engine and extended it for my games.
Here's the map of Fall of 21XX implemented to draw and remove the tiles dinamically. For comparison, the original Fall of 21XX can be played here.
You need to upgrade your Flash Player
Please visit Flash Player's download page to upgrade. Then return here to try again.
The difference? Well, the whole map is available. You can reach the boss room and return to beginning of the map, with no major perfomance impact. This is pretty trvial nowadays but for me it was a huge milestone.
The fewer tiles visible at a given time, the faster the engine moves. On slow system, there'll be slow motion on places where many tiles are present. I've placed many in purpose here and there to test. Definetily this engine (or more specific, Flash) can't handle screens filled of tiles, let alone, screen filled of 16x16 tiles, although with every year as computers get faster this becomes less of an issue. The key in this engine is that it uses Super Tiles, this is, 16x16 tiles grouped on larger sections. These can be repeated to create the map. For more information check Strille's tutorial.
Actually I found another advantage on the Super Tiles and it was on the level editor.
The engine can actually be used to create more traditional maps with only 16x16 tiles (in this case the Super Tiles contain only a single 16x16 tile). Though it works, some perfomance is lost when the map is drawn on the game. But the real problem comes when editing the map. As the level editor, I use the Flash IDE. In another FLA file, I create the Super Tiles, and start to layout the map. Then when publishing, I write on the output window an array with the info of the map encoded. Then this text is pasted on the actual FLA file of the game, where the map data is parsed and the map is created. XML or any format of your preference can be used for this, but for testing purposes I just used simple arrays.
The Flash IDE performs well with huge maps consisting of big super tiles, and writes the array fast. But on a huge map, with tiny 16x16 super tiles, the Flash IDE performs very bad, and runs the risk to hang up on slow systems. So save your work often just in case.
Now the question is, how big can these map be?