How can I support objects larger than a single tile in a 2D tile engine?

Posted by Yheeky on Game Development See other posts from Game Development or by Yheeky
Published on 2014-06-24T22:51:40Z Indexed on 2014/08/25 10:34 UTC
Read the original article Hit count: 416

Filed under:
|
|

I´m currently working on a 2D Engine containing an isometric tile map. It´s running quite well but I'm not sure if I´ve chosen the best approach for that kind of engine. To give you an idea what I´m thinking about right now, let's have a look at a basic object for a tile map and its objects:

public class TileMap {
   public List<MapRow> Rows = new List<MapRow>();
   public int MapWidth = 50;
   public int MapHeight = 50;  
}

public class MapRow {
   public List<MapCell> Columns = new List<MapCell>();
}

public class MapCell {
   public int TileID { get; set; }
}

Having those objects it's just possible to assign a tile to a single MapCell. What I want my engine to support is like having groups of MapCells since I would like to add objects to my tile map (e.g. a house with a size of 2x2 tiles). How should I do that? Should I edit my MapCell object that it may has a reference to other related tiles and how can I find an object while clicking on single MapCells? Or should I do another approach using a global container with all objects in it?

© Game Development or respective owner

Related posts about 2d

Related posts about engine