Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

I've worked with tile-based engines before (a few years ago when I was pretty green). Now that I know a bit more, I want to revisit tile-based engines but I want to approach it correctly. I want to know two things: what is the best way to store the tiles, and what is the best way to store the levels?

For the first question: The tiles should be stored in sets, like a 10x10 grid of 40x40 tiles stored in a 400x400 image. Right? So when it's displayed, do you just place the entire image on the screen and only show the part of the image you want? And in that case, wouldn't it create a significant amount of overhead for a bunch of unused image? Or do multiple copies of the same image use the same cache?

For the second question: Should the levels be stored as two dimensional arrays? Serialized in a database? Or what?

share|improve this question
    
Might be worth to take a search around the site, tons of questions like this already been asked / answered. –  thedeadlybutter Feb 8 '13 at 23:33
    
Sounds a lot like design paralysis to me. Just pick something that seems like it'll work for your project then come back when you have a specific problem you need solved. –  Tetrad Feb 9 '13 at 0:01
add comment

1 Answer 1

up vote 0 down vote accepted

It's really not a huge deal - as long as you do it one way and keep it consistent. There's a lot of ways you COULD do this; but I guess the simplest way is to just keep a few basic data structures and serialize it down. This will be fastest way to get your game going, and if you keep it flexible, you can always add more information and refactor as you go.

Consider:

Create a map class or structure and store some specific details like name, description and the like. Keep a list (depends on your language) of all map layers available to that map. Those layers then can contain a two dimensional array of 'MapTile's. The map tile can store data about a specific map tile. This is a simple and yet very flexible approach.

There's nothing really fancy about it - if you come to an important issue that is more specific, be sure to ask!

share|improve this answer
    
Thanks, that sounds like a good approach! Just wanted to make sure I wasn't starting in the wrong direction. Nothing like spending a few hours designing a system only to decide you want to scrap it later. I appreciate the advice! –  Luke Godfrey Feb 9 '13 at 1:29
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.