2d tile maps

Started by
0 comments, last by fpsgamer 15 years, 10 months ago
Hi i am trying to dynamically size my map i have a map class that has a pointer to my multidimensioanl array i.e. char **m_Level; this gets initialized in the constructor i.e CMap(TCHAR *name, int width, int height); but what i want to do is assign **m_Level to manual 2d dimensional variable i.e int *map1[] = {0, 0, 0, 0 0, 0, 0, 0}; to this method AssignMap(map1); i have a method called AssignMap(int *map[]) { for(int x=0; x<m_Width; x++) { for(int y=0; y<m_Height; y++) { m_Level[x][y]=map[x][y]; } } } but i am not sure this is correct?
Advertisement
You have to clarify your question. Your post goes all over the place and is somewhat incoherent.

Why don't you post some of your actual code.

Also if you want to pass a 2D array to a function the signature should be (Assuming C, or C++):

void AssignMap(int (*map) []); // note the brackets

2D arrays decay to "pointers to arrays". 1D arrays decay to plain ol' pointers.

This topic is closed to new replies.

Advertisement