This repository has been archived on 2023-05-13. You can view files and clone it, but cannot push or open issues or pull requests.
mipt_cpp/seminar13_polymorphism/arkanoid/paddle.hpp

26 lines
618 B
C++
Raw Normal View History

2023-01-04 13:46:41 +03:00
struct Paddle
{
inline static const sf::Color color {sf::Color::White};
sf::Vector2f position;
sf::Vector2f size;
Paddle() {}
Paddle(sf::Vector2f position, sf::Vector2f size) : position(position), size(size) {}
sf::FloatRect getBorder() const
{
return {position.x - size.x / 2.0f, position.y - size.y / 2.0f, size.x, size.y};
}
void draw(sf::RenderWindow& window)
{
static sf::RectangleShape shape{};
shape.setPosition(position - size / 2.0f);
shape.setSize(size);
shape.setFillColor(color);
window.draw(shape);
}
};