Tile::Tile(int p_tileType, sf::Vector2u p_spriteLoc,int p_ssNum, sf::Vector2u p_tileDims ) { setSpriteLoc(p_spriteLoc); setTileType(p_tileType); setSSNum(p_ssNum); setTileDims(p_tileDims); }
void FloodFill::floodFill(TrackTile & tile, QAction * action, const QString & typeToFill, MapBase & map) { static const int DIRECTION_COUNT = 4; // Coordinates of neighbor tiles can be calculated by adding these // adjustments to tile coordinates. static const QPoint neighborAdjustments[DIRECTION_COUNT] = { QPoint( 1, 0), // right QPoint( 0, -1), // up QPoint(-1, 0), // left QPoint( 0, 1) // down }; setTileType(tile, action); QPoint location = tile.matrixLocation(); for (int i = 0; i < DIRECTION_COUNT; ++i) { int x = location.x() + neighborAdjustments[i].x(); int y = location.y() + neighborAdjustments[i].y(); if (x >= 0 && y >= 0) { auto tile = std::dynamic_pointer_cast<TrackTile>(map.getTile(x, y)); if (tile && tile->tileType() == typeToFill) { FloodFill::floodFill(*(tile.get()), action, typeToFill, map); } } } }
Tile::Tile() { setTileType(6, 0); }