From 65741d9b3906c02ccfcbcd82eaa3e248e7da91b0 Mon Sep 17 00:00:00 2001 From: Rodrigo Delduca Date: Sun, 27 Oct 2024 05:53:41 -0300 Subject: [PATCH] Work in progress --- src/entity.cpp | 8 ++++---- src/entity.hpp | 18 +----------------- src/fontfactory.cpp | 4 ++++ 3 files changed, 9 insertions(+), 21 deletions(-) diff --git a/src/entity.cpp b/src/entity.cpp index 9712c57..e97a3ce 100644 --- a/src/entity.cpp +++ b/src/entity.cpp @@ -19,10 +19,6 @@ std::string entity::kind() const { return _props.kind; } entityprops entity::props() const { return _props; } -void entity::set_props(entityprops props) noexcept { - _props = std::move(props); -} - int32_t entity::x() const noexcept { return _props.position.x(); } int32_t entity::y() const noexcept { return _props.position.y(); } @@ -93,6 +89,10 @@ bool entity::colliding_with(const entity &other) const noexcept { _props.position.y() + _props.size.height() > other._props.position.y(); } +void entity::set_props(entityprops props) noexcept { + _props = std::move(props); +} + void entity::set_placement(int32_t x, int32_t y, anchor) noexcept { int32_t _x{x}, _y{y}; _props.position.set(_x, _y); diff --git a/src/entity.hpp b/src/entity.hpp index e6c9ea2..25b25ab 100644 --- a/src/entity.hpp +++ b/src/entity.hpp @@ -11,56 +11,42 @@ namespace framework { class entity : public std::enable_shared_from_this { public: + entity(const entityprops &&props); virtual ~entity(); static std::shared_ptr create(const entityprops &&props); uint64_t id() const noexcept; - std::string kind() const; virtual void update(double_t delta); - virtual void draw() const; bool colliding_with(const entity &other) const noexcept; entityprops props() const; - void set_props(entityprops props) noexcept; int32_t x() const noexcept; - int32_t y() const noexcept; void set_placement(int32_t x, int32_t y, anchor anchor = anchor::none) noexcept; - void set_entitymanager(std::shared_ptr entitymanager) noexcept; - void set_resourcemanager(std::shared_ptr resourcemanager) noexcept; void set_onupdate(const std::function)> &fn) noexcept; - void set_onanimationfinished(const std::function)> &fn) noexcept; - void set_onmail(const std::function, const std::string &)> &fn) noexcept; void set_velocity(const math::vector2d &velocity) noexcept; - void set_pixmap(std::string_view filename); - void play_sound(std::string_view filename); - void set_flip(graphics::flip flip) noexcept; - void set_action(std::string_view action); - void unset_action(); std::string action() const; - geometry::size size() const noexcept; - bool visible() const noexcept; void dispatch(const std::string &message); @@ -68,8 +54,6 @@ class entity : public std::enable_shared_from_this { private: friend class entitymanager; - entity(const entityprops &&props); - entityprops _props; std::shared_ptr _entitymanager; std::shared_ptr _resourcemanager; diff --git a/src/fontfactory.cpp b/src/fontfactory.cpp index 260065c..97f6b3e 100644 --- a/src/fontfactory.cpp +++ b/src/fontfactory.cpp @@ -31,6 +31,10 @@ std::shared_ptr fontfactory::get(const std::string &face) { const auto format = surface->format; const auto separator = color(pixels[0], format); + static const auto black = color("#000000"); + static const auto white = color("#ffffff"); + static const auto mangeta = color("#ff00ff"); + for (auto y = 0; y < height; ++y) { for (auto x = 0; x < width; ++x) { const auto pixel = pixels[(y * width) + x];