Original Post
Hi, I'm kinda new to programming so bear with me. I'm trying to write a tile-based map for an rpg but I want the maps to be dynamic, vary in size and layer. I read a tutorial that said I should write it something like this struct tileStruct { char id; // tile id bool open; }; //walkable or nor tileStruct ***map; Could someone please help me figure out what to do with that or if there is a better way please tell me. I'm not the greatest with pointers. This is what my code looks like: I'm not even really sure what it does. Well, kinda but not enough to know how to fix it. Pleas help. :) void rpgmap::loadMap( std::string filename ) { ifstream infile;// file input infile.open( filename.c_str() );// open the file for reading infile >> myRows >> myCols >> myLayers; infile.ignore(1,' '); myMap = malloc(sizeof(tileStruct**) * myLayers); for(int layer = 0; layer < myLayers; layer++) { myMap[layer] = malloc(sizeof(tileStruct*) * myCols); for(int col = 0; col < myCols; col++) myMap[layer][col] = malloc(sizeof(tileStruct) * myRows); } // // load the tiles from the file // infile.close();// close the file so another one can be opened }