Advertisement

multidimensioned vectors

Started by March 07, 2002 08:13 PM
0 comments, last by evilclown 22 years, 6 months ago
I''m making a map class for my game. It''s supposed to load the map into a multidimensioned array. I thought it would be better to use vectors because the map will not always be the same size. Is there something wrong with this? I can''t get it to work. It causes the core to dump(or maybe it''s called fatal signal) The vector is declared as vector< vector<map_tile> > map_data; and the code is

  map_tile atile;
  int i;
  int j;

  //empty
  //map_data.clear();

  //set default
  atile.tileID = 0;
  for(i = 0; i < TILES_ON_W; i++) {
    for(j = 0; j < TILES_ON_H; j++) {
      map_data.push_back(atile);
    }
  }
 
Do you know a vector tutorial?
If map_data is a vector of type vector, why are you doing a push_back with a map_tile variable? You need to push_back a variable of type vector like this:

map_tile Tile;
vector TileVector;

TileVector.push_back(Tile);
map_data.push_back(TileVector);

This topic is closed to new replies.

Advertisement