Added a Background guecs component.

This commit is contained in:
Zed A. Shaw 2025-02-18 23:08:04 -05:00
parent 69a810b5a1
commit 3a6ba8445a
7 changed files with 78 additions and 56 deletions

View file

@ -42,10 +42,9 @@ namespace guecs {
shared_ptr<sf::RectangleShape> shape = nullptr;
void init(lel::Cell& cell) {
sf::Vector2f size{(float)cell.w, (float)cell.h};
sf::Vector2f size{float(cell.w) - 6, float(cell.h) - 6};
if(shape == nullptr) shape = make_shared<sf::RectangleShape>(size);
shape->setPosition({float(cell.x + 3), float(cell.y + 3)});
shape->setSize({float(cell.w - 6), float(cell.h - 6)});
shape->setFillColor(ColorValue::DARK_MID);
shape->setOutlineColor(ColorValue::MID);
shape->setOutlineThickness(1);
@ -65,6 +64,31 @@ namespace guecs {
std::string name;
};
struct Background {
float x = 0.0f;
float y = 0.0f;
float w = 0.0f;
float h = 0.0f;
shared_ptr<sf::RectangleShape> shape = nullptr;
Background(lel::Parser& parser) :
x(parser.grid_x),
y(parser.grid_y),
w(parser.grid_w),
h(parser.grid_h)
{}
Background() {}
void init() {
sf::Vector2f size{float(w), float(h)};
if(shape == nullptr) shape = make_shared<sf::RectangleShape>(size);
shape->setPosition({float(x), float(y)});
shape->setFillColor(ColorValue::MID);
}
};
class UI {
public:
DinkyECS::World $world;