Archived

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

lpsoftware

map array problems

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
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