Game Development Stack Exchange is a question and answer site for professional and independent game developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I've been thinking about this for a while. I have a 2D tile bases platformer in XNA with a large array of tile data, I've been running into memory problems with large maps. (I will add chunks soon!)

Currently, Each tile contains an Item along with other properties like how its rotated, if it has forground / background, etc.

An Item is static and has properties like the name, tooltip, type of item, how much light it emits, the collision it does to player, etc. Examples:

public class Item
    public static List<Item> Items;

    public Collision blockCollisionType;
    public string nameOfItem;
    public bool someOtherVariable,etc,etc

    public static Item Air
    public static Item Stone;
    public static Item Dirt;
    static Item()
       Items = new List<Item>() 
            (Stone = new Item()
                nameOfItem = "Stone",
                blockCollisionType = Collision.Solid,
            (Air = new Item()
                nameOfItem = "Air",
                blockCollisionType = Collision.Passable,


Would be an Item, The array of Tiles would contain a Tile for each point,

public class Tile
     public Item item; //What type it is
     public bool onBackground;
     public int someOtherVariables,etc,etc

Now, Most would probably use an enum, or a form of ID to identify blocks. Well my system is really nice just to find out about an item. I can simply do tiles[x,y].item.Name To get the name for example. I realized my Item property of the tile is over 1000 Bytes! Wow! What I'm looking for is a way to use an ID (Int or byte depending on how many items) instead of an Item but still have a method for retreiving data about the type of item a tile contains.

share|improve this question
up vote 0 down vote accepted

Item is a class, the Tile class only stores a reference to it.

Your items are static instanced, so you have a few, and the tiles are sharing them... so the name is shared by all the tiles, is the same name for all tiles that are linked to the same Item.

You know that you have to make chunks and split the map... go for it.

share|improve this answer
Thats what I was thinking, but I created a test class, and one with a Byte instead of an item made it significantly smaller. Then again, I think it's because I was serializing to get the size. – Cyral Nov 25 '12 at 0:03

Your Answer


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.