Tile-Based Games

An example of a tile set

One method we could use to develop our game would be to use a tile-based system to make our game. In a tile-based system, the game screen would be split up into a grid. Each level would have a tile map, which contains all the graphics that need to be used in each square of the grid. We could then re-use these squares each time we need that tile. The advantage of this is that it would save game memory and make the game run faster.

From a hardware performance standpoint, thew primary advantage of the tile map over the frame buffer is an exponential reduction in the amount of memory needed to store one screen’s worth of information – and by extension, an equal reduction in the amount of processing power and time needed to make changes to that screen. Giles does the math: “a game with 256 by 256 pixels would need a 32 by 32 tilemap to cover that area with 8×8 graphics tiles… At 4 cycles per operation, clearing the screen happens in a brisk 1/250th of a second for a 1 MHz CPU.” In short a tile map requires 64 times less memory and processing time.

(Wolf, 2012)

Traditionally this approach has been used for early platformers as it meant that large levels could be displayed without using a lot of processing power from redrawing assets from scratch. Although the saving memory is not as critical on modern smartphones compared to earlier handheld gaming consoles, using a tile based approach might help our game run quicker and therefore improve the player experience.

The level editor in Tiled

One of the ways to use a tile-based approach in Swift and Sprite Kit would be to first make the levels in a tile map editor. Tiled is a popular and free editor which could be used to do this. A advantage of using it is that it allows the designer to separate all the objects out into different layers depending on how they affect the player. For example, all hazards (which harm the player) can be on one layer and all obstacles (which just impede them) are on another.

Screen shot from the Ray Wenderlich tutorial, How to Make a Platform Game Like Super Mario Brothers

Screen Shot 2015-04-16 at 13.08.58
Code which uses the positioning of the player to give certain tiles indexes. This can then be used to evaluate what happens next in the game , for example if the player is not stood on a tile, he will fall.

To further my understanding of tile sets I followed a tutorial on creating a Super Mario type game using Tiled. Although it was in Objective-C it was useful to learn as it helped me see how the tiles would be used in the game, and the structure of the game cycle (which I researched in my previous post). Using indexes to reference the squares around the player, the game can then check what behavior to follow next, depending on what tile type that index calls.

Although the end product ran quite well and was quite easy to code, ultimately whether we use this kind of level design depends on the art designers and whether they would be happy to use a program such as Tiled to organize assets. As well using a tile based system could unnecessarily limit game play options as iPhone architecture can easily handle more complicated procedures, so if we choose to use a tile based system we might be limiting the interactions between the player and objects.

Wolf, M. (2012). Before the crash. Detroit: Wayne State University Press.

Mapeditor.org, (2015). Tiled Map Editor. [online] Available at: http://www.mapeditor.org/ [Accessed 16 Apr. 2015].

Ray Wenderlich, (2015). How to Make a Platform Game Like Super Mario Brothers – Part 1 – Ray Wenderlich. [online] Available at: http://www.raywenderlich.com/15230/how-to-make-a-platform-game-like-super-mario-brothers-part-1 [Accessed 13 Mar. 2015].