map array problems
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
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}
};
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}
};
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement