I didn't have to resort to this, because I'm sure this is a simple problem. However, I've been dealing with this for quite a while now. For some reason it keeps saying my vector is out of range.
I've been setting breakpoints and such, reading the values of my variables.
Map* NewMap(int w, int h)
{
Map* map;
int x = 0;
int y = 0;
int mapTileArea = w * h; // Make a interger that holds the area of map tiles
map = new Map;
// Set variable values
map->setMapH(h);
map->setMapW(w);
map->setMaxTiles(mapTileArea);
// Pre-allocate memory for speed
map->Tiles .reserve(mapTileArea + 1);
map->Tiles2.reserve(mapTileArea + 1);
map->Tiles3.reserve(mapTileArea + 1);
map->Tiles4.reserve(mapTileArea + 1);
map->Tiles5.reserve(mapTileArea + 1);
map->Tiles6.reserve(mapTileArea + 1);
for(int t = 0; t < mapTileArea; t++)
{
// Add a new tile to the map's vector
map->Tiles .push_back(new Tile(x, y, 2)); // Fill the bottom layer with "void" tiles
map->Tiles2.push_back(new Tile(x, y, 2)); // Fill the layer with transparent tiles
map->Tiles3.push_back(new Tile(x, y, 2)); // Fill the layer with transparent tiles
map->Tiles4.push_back(new Tile(x, y, 2)); // Fill the layer with transparent tiles
map->Tiles5.push_back(new Tile(x, y, 2)); // Fill the layer with transparent tiles
map->Tiles6.push_back(new Tile(x, y, 2)); // Fill the layer with transparent tiles
x += TILE_W;
if(t == mapTileArea)
{
std::cout<< "hai";
}
// if x goes too far...
if(x < map->getMapW())
{
x = 0;
y += TILE_H;
}
}
return map;
}
It's somewhere in the loop, but I don't know why it's saying this.
for(int t = 0; t < mapTileArea; t++)
{
// Add a new tile to the map's vector
map->Tiles .push_back(new Tile(x, y, 2)); // Fill the bottom layer with "void" tiles
map->Tiles2.push_back(new Tile(x, y, 2)); // Fill the layer with transparent tiles
map->Tiles3.push_back(new Tile(x, y, 2)); // Fill the layer with transparent tiles
map->Tiles4.push_back(new Tile(x, y, 2)); // Fill the layer with transparent tiles
map->Tiles5.push_back(new Tile(x, y, 2)); // Fill the layer with transparent tiles
map->Tiles6.push_back(new Tile(x, y, 2)); // Fill the layer with transparent tiles
x += TILE_W;
if(t == mapTileArea)
{
std::cout<< "hai"; // Set a breakpoint here.
}
// if x goes too far...
if(x < map->getMapW())
{
x = 0;
y += TILE_H;
}
}