What is a tileset?
What are the advantages of using tilesets?
There are tutorials and examples on making fast loop level editors, etc around TDC. There's even level editors examples that use tilesets. This is not the focus of my article. My focus is the discussion of tilesets, their advantages and how easily they can be incorporated into your own level editor or game. An excellent article was written by cake some time ago (linked in the Resources section) which I thought I would elaborate on because it had great ideas/examples but didn't explain the Active Picture Object's use that well.
What is a tileset?
A tile set is collection of smaller images called tiles (typically of uniform size) which have been combined into a single larger image. Tile sets are often used in 2D video games to create complex maps from reusable tiles within the set. When a tile set based map is displayed, the tiles that are stored within it are used to reassemble the map for display. This technique is seen in games designed to run on portable systems such as Nintendo's Game Boy Advance system or a cellular phone ... Using tile sets reduces the amount of system memory required to display maps since it allows for the same tiles to be reused multiple times in a map. It also reduces amount of artwork needed for individual maps since many different ones can be created from the same tileset. In order for maps made from tile sets to appear more distinctive, games typically display them with a different tile set for each unique environment.
I made this tileset myself a few years ago, and that's all well and good but I had no idea how to implement it into a game as just the sheet image, so I would use a graphics editing program to cut out each tile and create a new backdrop or active object for every tile that I had made. Simple enough, right? Yes, easy, but that's only if you have around 10 unique tiles that you use. Suppose you are creating a massively complicated map with your own level editor using each tile as an active object to paste on to the level and you have 100 unique tiles, maybe even 200. That means cutting out each tile, pasting and cropping it in MMF, which would get extremely tedious and boring, not to mention you may need a unique event for each tile to place it.
You would be wasting precious time you could be spending actually creating beautiful levels and scenery!
There's many reasons that tile sets are an advantage for your game:
Game mechanics - Many games actually run on a grid-based system, be it RPG, strategy, board game, anything really. Even if your game doesn't run off a grid, it is useful to be able to reuse tiles in a map to create a large playfield. The more tiles you use, the less grid-like you can make the game appear.
Save time - with an image that contains many tiles, you will not need to cut out each one individually or create a new object for every tile you use.
Save memory and filesize - It's only logical to assume that by using one single image, you can save yourself from creating an MMF frame with 100 unique objects that clutter the field, your object list, will increase your filesize and slow your game down eventually.
Save events - Using a single tileset image will save you events as you can use simple calculations to make a level editor know which tile it is using without specifically naming each one and making an event to place it. (Refer to cake's article)
Save editing pain - Oh dear, you just realised that tile doesn't mesh with it's surrounding tiles, or the colours aren't right for these 50 tiles. Save yourself the horror and simply edit the tile set sheet.
Customization - Using tile sets, it is your choice to allow players to create their own truly customized levels in your editor, and opening many more possibilities. Not just in environment, but HUD/GUI graphics too!
Take the next step - If you aren't already using tiles, or are using them in a tedious manner, take your game creation to the next step by using something that is universal to all gaming programming/languages - tile sets!
So let's look at a simple way to get started.
I've made an example file for your download at this location:
And I will now run through it (with images) to explain how easily you can use the Active Picture Object to implement tilesets. I recommend looking at this example .MFA file, but if you don't need it, I've outlined pretty much everything here too.
Your most important thing: the Active Picture Object.
When you place it on your frame, you will be given this dialogue.
Select your tile set. Transparent colour can be set in the properties frame in MMF.
Now for the important part - the events. Using just two events, we can create a very simple copy/paste from the Active Picture Object, using it's action Create Backdrop Object.
Any problems you might have with it not copying and pasting from/to the right places, you will need to double check if you have the right uniform size tiles, any offsets to consider and remember that tile sets are made to be compressed to save size - put your tiles directly next to eachother, don't be afraid because you can easily cut them out again using this method or in your graphics editing program show a grid for your tile sizes to see where each tile begins/ends if you get confused. I hope that the images and example have spelt it out for you fairly well - and remember, the size is not limited to 16 pixel tiles. This is your choice, though numbers in the power of 2 are standard sizes (16, 32, 64, 128, 256, 512 .. etc) used for all sorts of things.
And this is just the beginning, once you understand how easy it is to do this, you can incorporate this method into your level editor, using arrays (or INIs) and fast loops to create a functional, powerful editor which allows for great customization in your game and isn't just the player's benefit, it makes your game creation more streamlined and is a useful tool. (Just look back at the advantages of using tile sets!) Remember that this is for backdrops also, active objects will still need to be handled in the usual manner, but this allows for more time doing those rather than wasting time cutting out tiles and assembling them individually on your frame.
I hope it's easy to understand, but I guess the only way to really understand is to have a go at it. This tutorial sort of bridges the gap between cake's article on External Data and Sketchy's article on Tile Based Games. In combination I think the three articles could fuel a really smart editor. Not that there isn't already some great map editors on TDC
@Cecil: I thought it might be useful and I concur, citations would be great help in all articles because authors could post links to related subjects or further reading/tutorials.
@maVado: not 100% what you mean, are you talking about just a fastloop level editor? I have done that before, but yeah using many actives When I understood that tile sets were so easy, now I can incorporate them into an editor!
I assume you are talking about a scrolling map - this is something that would need to be implemented in the level editor system and a part of fast loops. Not directly related to the idea of tilesets. I have myself wondered about scrolling levels and I have an idea of how it would work, perhaps I should make an articles on that, because I'm sure of a method though I'm yet to try it out.
Keeping the tileset and frame follow scrolling shouldn't be hard to implement, that's just basic GUI coding fiddling such as making sure things are read from correct placement etc.
It's cool you've been experimenting with scrolling and level editing, I am sure that MMF can support this. I wouldn't go so far as to say that MMF2 has not been designed for this kind of work, I really think that MMF2 has a lot of potential to reach which maybe hasn't yet by many people.
Hey, it's really cool to see efforts to bolster the knowledge-base on level editing!
Kind of inspires me to go back to my article and update it (man I wrote that 5 years ago and it makes me wince now ).
If you want scrolling level editors, use layers in MMF2 to make your GUI always on top of the workspace. You'll need to have some kind of scrolling controls (arrow keys are quick and easy, but you can do minimaps and custom scrollbars).
I'm still unsure what the issues people are having with scrolling are? I'd be happy to elaborate on it in a new article.