Solved the problem, thank you for your help! I would still like to know more about a memory management system, it would be a good way for me to push my knowledge.
Here's the revised version:
MapGrid.h
class MapGrid
{
public:
MapGrid();
void createTile();
void adjustTilePosition();
void populateGrid(MapTile* mapTile);
int tileCount;
float x_offset;
float y_offset;
std::vector<MapTile*> mapTiles;
}
MapGrid.cpp
MapGrid::MapGrid()
{
x_offset = 0.0f;
y_offset = 0.0f;
tileCount = 0;
}
void MapGrid::createTile()
{
MapTile* newMapTile = new MapTile(x_offset, y_offset);
tileCount++;
adjustTilePosition();
populateGrid(newMapTile);
}
void MapGrid::adjustTilePosition()
{
if (tileCount % 10 == 0)
{
x_offset = 0;
y_offset += 50;
}
else
{
x_offset += 50;
}
}
void MapGrid::populateGrid(MapTile* mapTile)
{
mapTiles.push_back(mapTile);
}
I know raw pointers are frowned upon, so I'll use a unique_ptr.
Thanks again.
Edit: unique_ptr was giving me some problems, so I switched to shared_ptr.