David Stockdale's Scrapcode

Map Storage

The first challenge I encountered when creating a tile-based mobile game was deciding how I would store the various maps upon which various combat scenarios would take place.

What I eventually settled on was an array of integers with each number representing a different type of tile, these arrays were arranged in such a way that the integers were displayed within the xml file in the same layout as the actual map.

This may not have been the best choice for storing the map info but I implemented it anyway as I enjoyed the ease with which I could edit the maps.

A (very small) look at how the map integer arrays are laid out within my code.

3 x 3

As you may have noticed above the integer array has been laid out into three columns of three rows, each of these sections represent enough tiles to fill the combat screen of my app.

When I first tested the combat screen of my app I only created a map big enough to fill the screen before deciding that each map should contain nine such areas in order to give the player the illusion of a bigger world.

The middle section of the map integer array shown above.

I accomplished this by simply making the integer array nine times longer, although looking back I realise it may or may not have been simpler to just have nine separate arrays.

These new larger maps however brought with them a new problem: if the player can move around in an area larger than the screen, how should I go about ensuring that the player is always on the screen?

The middle section of the map integer array shown above when displayed.

Leave a Reply