Deconstructing The Spiral - Part 2

Tuesday 12 April 2011 at 5:00 pm.

So what is needed for a tile engine, anyway? That depends, of course, on what its function is. So the first thing to do is identify what your needs are. The RPG Starter Kit tile engine fit several of my basic needs: multiple drawing layers, collision data, portal information to jump between maps. But my total set of needs were still different than what it offered.

The first thing that it did, that I had to work to overcome, was the way that it handled movement. With the starter kit, it has a freeform movement ARPG style, which I didn't want because I was trying to go for the classic CRPG style, moving the characters along the grid of tiles. This ended up leading to quite a bit of work for me to add, as I ended up with all kinds of behaviors along the way before it was stable: map coordinates becoming out of sync, sprites not lining up along the grids anymore when scrolling, multiple direction inputs causing it to move in more then one direction and getting off grid, and even the entire collision detection being fooled by their movement and walking right through walls! Adding to the fact that the input system was bound to the tile engine, so having to work with it like that to fix things whever keyboard would break gamepad input or vice/versa, when I should have completely separated the input entirely. 

Another difficulty was the way it drew things, which led to several different unusal problems. As it is, since it is just meant to be an example, the kit draws the entire map, including a lot of wasted draws off-screen. The world map for Spiral Island is 200x200 tiles, leading to - with a 96x96 tile size at 1080p (I adaptively selected tilesets depending on resolution) - a whopping 368 Million pixels being drawn every frame to a space thats only about .5% that size. Obviously we couldn't be having that, so I rewired it to only draw what was on the screen and the small overflow for scrolling. However, the other problem that led to was when I came to corners where the screen stopped scrolling, as I found that it didin't draw tiles based on an absolute position, but instead relative to where the player was. So if the character is in the bottom left corner of the screen, and its only drawing 20 tiles across the screen, half of the screen would be blank because there was only half the tiles on the screen at the time. So not only does that have to be adaptive to the aspect ratio, it leads to the additional problem of not being able to script a separate camera for cutscenes without hiding the PC and moving it along as the camera, and having to store their position so you can then return them.

There were a couple minor things as well, such as the particular way the portals worked, which ended up leading me to alter the map format to support a more streamlined set of information, as well as adding the ability to extend with additional data (such as zone information for random encounters). It also was designed to combine all of the NPC data together on the map, which I wasn't particularly pleased with, because I didn't want to lose both map and NPC data all at once if one particular edit became corrupted, and also it didn't make multiple script sets (for translation and alternate New Game+ script sort of scenarios) very feasible. And so that was where I fist began to implement my changes, by creating a new NPC data structure. Which led to a whole lot more mistakes.

No comments


Title: Deconstructing The Spiral - Part 2
Date posted: 12 04 11 - 17:00
Next entry:   » Why I'm Not Worried A…
Previous entry: « Deconstructing The Sp…