Which way to store this data is effective?

Posted by Tattat on Stack Overflow See other posts from Stack Overflow or by Tattat
Published on 2010-04-05T14:05:25Z Indexed on 2010/04/05 14:13 UTC
Read the original article Hit count: 208

I am writing a game, which need a map, and I want to store the map. The first thing I can think of, is using a 2D-array. But the problem is what data should I store in the 2D-array. The player can tap different place to have different reaction. So, I am thinking store a 2D-array with objects, when player click some position, and I find it in the array, and use the object in that array to execute a cmd. But I have a concern that storing lots of object may use lots of memory. So, I am think storing char/int only. But it seems that not enough for me. I want to store the data like that:

{
Type:1
Color:Green
}

No matter what color is, if they are all type 1, the have same reactions in logic, but the visual effect is based on the color. So, it is not easy to store using a prue char/int data, unless I make something like this:

 1-5 --> all type 1. 1=color green , 
 2=color red, 3 = color yellow.... ...
 6-10 --> all type 2. 2 = color green,
 2 = color red ... ...

So, do you have any ideas on how to minimize the ram use, but also easy for me to read... ...thx

© Stack Overflow or respective owner

Related posts about iphone-sdk

Related posts about objective-c