You'll have to forgive my ignorance when it comes to these sorts of issues. I'm new to C++ and even newer to programming on the PPC. So when it comes to things like limited memory and stack overflows, I have to admit I'm quite an idiot. So please bear with me.
My game dies upon initialization.
I've stepped through with the debugger, trying to figure out where the problem is. I believe I've isolated the problem, because I ripped out two Classes which control the level and current map, and the header containing the level data. Once that was done, the game initialized and displayed the main menu.
My level data is broken up into several multidimensional arrays.
To get an idea, there are 16 rooms per level. Tiles are 16x16, and rooms are 320x240 in size. This means 300 tiles per room. 4800 tiles per map.
The current set up for objects is 4 max per level, and 16 rooms (obviously). This comes to 64 objects per level.
The map_ent_t struct is as follows:
This information is global data (I currently have yet to implement loading level data from a file).
Now here's where my ignorance comes into play. Is this data pushed on to the stack? If it is, then this would explain why my game blows up on initialization. And it also begs the question: is it going to be possible to hold game data like this within my application, or am I going to have to create a level loader and load the data from the file?
This also brings me to another problem. My Level class holds data very similarly. It has multidimensional arrays almost identical to the above (except they hold more information, because it actually creates the data and holds a tile_t). Should I change this so it dynamically allocated the array and holds the information in memory (the heap)? Will this also solve part of my problem?
Thanks for the help!
EDIT:
I've included the leveldata.h file (so you can see the actual code for it).
Also, here's the Level class:
My game dies upon initialization.
My level data is broken up into several multidimensional arrays.
- Code:
static map_ent_t levelOneObjects[ROOMS_PER_LEVEL][MAX_OBJECTS_PER_ROOM];
static BOOL levelOneTiles[ROOMS_PER_LEVEL][ROWS_PER_ROOM][COLS_PER_ROOM];
To get an idea, there are 16 rooms per level. Tiles are 16x16, and rooms are 320x240 in size. This means 300 tiles per room. 4800 tiles per map.
The current set up for objects is 4 max per level, and 16 rooms (obviously). This comes to 64 objects per level.
The map_ent_t struct is as follows:
- Code:
typedef struct tagMAPENT
{
// r/c = Row/Col of the tile to spawn on.
tagMAPENT(DWORD cloneID, DWORD r, DWORD c)
{
this->CloneID = cloneID;
this->SpawnTile.x = c;
this->SpawnTile.y = r;
}
DWORD CloneID;
POINT SpawnTile;
} map_ent_t;
This information is global data (I currently have yet to implement loading level data from a file).
Now here's where my ignorance comes into play. Is this data pushed on to the stack? If it is, then this would explain why my game blows up on initialization. And it also begs the question: is it going to be possible to hold game data like this within my application, or am I going to have to create a level loader and load the data from the file?
This also brings me to another problem. My Level class holds data very similarly. It has multidimensional arrays almost identical to the above (except they hold more information, because it actually creates the data and holds a tile_t). Should I change this so it dynamically allocated the array and holds the information in memory (the heap)? Will this also solve part of my problem?
Thanks for the help!
EDIT:
I've included the leveldata.h file (so you can see the actual code for it).
Also, here's the Level class:
- Code:
class Level
{
public:
Level();
~Level();
void Load(DWORD bgIDs[], BOOL tiles[][ROOM_TILE_ROWS][ROOM_TILE_COLS], map_ent_t objects[][MAX_OBJECTS_PER_ROOM], map_ent_t player);
void Unload();
void LoadRoom(DWORD roomID);
private:
entity_t* LoadEntity(const map_ent_t& mapEnt, DWORD room);
DWORD m_bgIDs[ROOMS_PER_LEVEL];
tile_t m_tiles[ROOMS_PER_LEVEL][ROOM_TILE_ROWS][ROOM_TILE_COLS];
entity_list_t m_objects[ROOMS_PER_LEVEL];
entity_t* m_pPlayer;
};
Attachments:
leveldata.h (37 KB)