class SFML_GRAPHICS_API Drawable
{
public:
////////////////////////////////////////////////////////////
/// \brief Virtual destructor
///
////////////////////////////////////////////////////////////
virtual ~Drawable() {}
protected:
friend class RenderTarget;
////////////////////////////////////////////////////////////
/// \brief Draw the object to a render target
///
/// This is a pure virtual function that has to be implemented
/// by the derived class to define how the drawable should be
/// drawn.
///
/// \param target Render target to draw to
/// \param states Current render states
///
////////////////////////////////////////////////////////////
virtual void draw(RenderTarget& target, RenderStates states) const = 0;
};
class SFML_GRAPHICS_API Shape : public Drawable, public Transformable
{
public:
virtual ~Shape();
// нужно иметь доступ к этим методам ->
void setTexture(const Texture* texture, bool resetRect = false);
void setTextureRect(const IntRect& rect);
void setFillColor(const Color& color);
// и другие методы..
static sf::Drawable* drawObject(LevelObject& object, sf::RenderWindow &window) {
if(!object.hidden) {
if(object.lobjecttype == LevelObjectType::RECTANGLE) {
sf::RectangleShape* rectangleShape = new sf::RectangleShape(sf::Vector2f(object.objectWidth, object.objectHeight));
rectangleShape->setPosition(sf::Vector2f(object.objectX, object.objectY));
if(object.objectRotation.has_value()) {
rectangleShape->setOrigin(object.objectWidth / 2.f, object.objectHeight / 2.f);
rectangleShape->setRotation(object.objectRotation.value());
}
rectangleShape->setFillColor(object.objectColor);
window.draw(*rectangleShape);
return rectangleShape;
}
}
fetchall()[0][0]