void TileLayer:: draw(Camera* cam) { for (int row = getTileYTop( cam->getY() ); row <= getTileYBottom(cam -> getY() + (float)cam ->getHeight()); row++) { for (int col = getTileXLeft(cam -> getX() ); col <= getTileXRight(cam -> getX() + (float)cam -> getWidth()); col++) { int index = col + row * nColumns; if( ppTileTmx[ index ] ->getID() == 0) continue; TileSet* tileSet = tileSets[getTileSet(ppTileTmx[ index ] ->getID())]; int tileID = ppTileTmx[ index ] ->getID () - tileSet ->firstGridID; // ex : 128th represent by 127 in the 1D array int tileIDinSet = tileID; tileID = tileSet -> getCurrentID(tileID); if(tileID != -1 ) { tileIDinSet = tileID; } int colInSet = tileIDinSet % tileSet -> nColumns; int rowInSet = tileIDinSet / tileSet -> nColumns; int dx = tileSet -> margin + (colInSet) * ( tileSet ->spacing + tileSet -> tileWidth ) ; int dy = tileSet -> margin + (rowInSet) * ( tileSet ->spacing + tileSet -> tileHeight ); ppTileTmx[index ] -> draw( tileSet ->pTexture, tileSize, tileSize,dx, dy, cam); } } }
void MapSection::postParse(const INIConfigSection& section, ValidationList& validation) { // parse rotations rotations_set.clear(); tile_sets.clear(); std::string str = rotations.getValue(); std::stringstream ss; ss << str; std::string elem; while (ss >> elem) { int r = stringToRotation(elem); if (r != -1) { rotations_set.insert(r); tile_sets.insert(getTileSet(r)); } else { validation.error("Invalid rotation '" + elem + "'!"); } } // check if required options were specified if (!isGlobal()) { world.require(validation, "You have to specify a world ('world')!"); texture_dir.require(validation, "You have to specify a texture directory ('texture_dir')!"); } }