Sign in to follow this  

2d tile maps

This topic is 3487 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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?

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites

This topic is 3487 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this