Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

lpsoftware

map array problems

This topic is 6680 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

Hello everyone, I''ve got a boggling problem here...well atleast for me I''m creating a vertically scrolling game (up AND down and not horizontal) which is 32 tiles high and 16 tiles wide, with square tiles with a side of 32 pixels. #define MAPSIZEX 16 #define MAPSIZEY 32 Ok, now I create the 2d map array: char map[MAPSIZEX][MAPSIZEY] = { 16 T I L E S 3 2 T I L E S When I try to compile, VC++ 6 gives me a message of "too many initializers" in the array. Why? I tried switching it so it was "char map[MAPSIZEY][MAPSIZEX}. This compiled, but of course it came out all screwy in the game and wouldn''t scroll up and down because the tiles were drawn horizontally. Thanks for any help, Martin

Share this post


Link to post
Share on other sites
Advertisement
You''re initializing it like:
char map[16][32] = {
{1, 2, ... 16},
{2, 2, ... 16},
...
{32, 2, .... 16}
};
Well for a [16][32] array you need to initializie it like:
char map[16][32] = {
{1, 2, 3,... 32},
{2, 2, 3,... 32},
...
{16, 2, 3, ...32}
};

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!