Ring::Ring(const float radius, const float hole, const unsigned int numberOfSides) : m_radius(radius) , m_hole(hole) , m_sectorSize(1.f) , m_sectorOffset(0.f) , m_numberOfSides(numberOfSides) , m_color(sf::Color::White) , m_primitiveType(sf::PrimitiveType::TrianglesStrip) , m_vertices((m_numberOfSides + 1) * 2) , m_texture(nullptr) , m_textureRect() { priv_updateVertices(); }
void TileMap::draw(sf::RenderTarget& target, sf::RenderStates states) const { if (m_redrawRequired) { priv_updateVertices(); priv_updateRender(); m_redrawRequired = false; } states.texture = &m_renderTexture.getTexture(); states.transform = getTransform(); target.draw(&m_render.front(), 4, sf::PrimitiveType::Quads, states); // final render is always 4 vertices & quad }
void Ring::setNumberOfSides(const unsigned int numberOfSides) { m_numberOfSides = numberOfSides; priv_updateVertices(); }
void Ring::setHole(const float hole) { m_hole = hole; priv_updateVertices(); }
void Ring::setRadius(const float radius) { m_radius = radius; priv_updateVertices(); }
void Ring::setSectorOffset(const float sectorOffset) { m_sectorOffset = sectorOffset; priv_updateVertices(); }
void Ring::setSectorSize(const float sectorSize) { m_sectorSize = sectorSize; priv_updateVertices(); }
void Ring::setTextureRect(const sf::IntRect& textureRect) { m_textureRect = textureRect; priv_updateVertices(); }
void TileMap::redraw() { priv_updateVertices(); priv_updateRender(); }