if(int(tiles.size()) != width*height) {
throw std::runtime_error("wrong number of tiles in tilemap.");
}
+
+ // make sure all tiles are loaded
+ for(Tiles::iterator i = tiles.begin(); i != tiles.end(); ++i)
+ tilemanager->get(*i);
}
TileMap::TileMap(int layer_, bool solid_, size_t width_, size_t height_)
if(start_x < 0) start_x = 0;
float start_y = roundf(context.get_translation().y);
if(start_y < 0) start_y = 0;
- float end_x = std::min(start_x + screen->w, float(width * 32));
- float end_y = std::min(start_y + screen->h, float(height * 32));
+ float end_x = std::min(start_x + SCREEN_WIDTH, float(width * 32));
+ float end_y = std::min(start_y + SCREEN_HEIGHT, float(height * 32));
start_x -= int(start_x) % 32;
start_y -= int(start_y) % 32;
int tsx = int(start_x / 32); // tilestartindex x
solid = newsolid;
if(solid)
flags |= FLAG_SOLID;
+
+ // make sure all tiles are loaded
+ for(Tiles::iterator i = tiles.begin(); i != tiles.end(); ++i)
+ tilemanager->get(*i);
}
void