I am reading in a simple map from a text file and storing it in a char** MAP variable. so MAP[X][Y] contains the characters for the map.
I have a Tile class that I want to store this MAP info in. MAP is just a temporary variable
I also have a World class that contains an array of these Tiles.
When I try to use a for loop to put all of MAP[X][Y] into world.tile[X][Y].charType, it crashes. Im probably overshooting an array, but I can''t find where.
Here is the code. Any help is appreciated...
Tile Class
class Tile
{
public:
char tileChar;
};
World Class
class World
{
public:
int cameraX;
int cameraY;
int mapMaxX;
int mapMaxY;
Tile tile[50][50];
};
Global Vars
char** tilemap;
World world;
Now tilemap is holding the MAP[X][Y] from above. This is tested and working fine.
world.mapMaxX = 13
world.mapMaxY = 9
Main Function
int main()
{
tilemap = readmap(); //This sets tilemap equal to MAP[X][Y]
//read from the file.
for (int i = 0; i < world.mapMaxX;i++)
{
for (int j = 0; j < world.mapMaxY;j++)
{
world.tile[i][j].tileChar = tilemap[i][j];
}
}
return 0;
}
~~~~~~~~~~~
Chris Vogel
~~~~~~~~~~~