diff --git a/CMakeLists.txt b/CMakeLists.txt index 03d5afb9..a3726bdf 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -12,14 +12,16 @@ add_subdirectory(${PROJECT_SOURCE_DIR}/lib/Ray) add_executable(bomberman sources/main.cpp - sources/Component/Drawable/DrawableComponent.hpp + sources/Component/Drawable/Drawable3DComponent.hpp + sources/Component/Drawable/Drawable2DComponent.hpp sources/Component/Movable/MovableComponent.cpp sources/Component/Movable/MovableComponent.hpp sources/Component/Position/PositionComponent.cpp sources/Component/Position/PositionComponent.hpp sources/System/Movable/MovableSystem.cpp sources/System/Movable/MovableSystem.hpp - sources/System/Renderer/RendererSystem.hpp + sources/System/Renderer/Renderer3DSystem.hpp + sources/System/Renderer/Renderer2DSystem.hpp ) target_link_libraries(bomberman wal ray) \ No newline at end of file diff --git a/sources/Component/Drawable/DrawableComponent.hpp b/sources/Component/Drawable/Drawable2DComponent.hpp similarity index 65% rename from sources/Component/Drawable/DrawableComponent.hpp rename to sources/Component/Drawable/Drawable2DComponent.hpp index 557a722c..45537d8a 100644 --- a/sources/Component/Drawable/DrawableComponent.hpp +++ b/sources/Component/Drawable/Drawable2DComponent.hpp @@ -6,17 +6,16 @@ #include "Component/Component.hpp" #include "Drawables/ADrawable2D.hpp" -#include "Color.hpp" namespace BBM { template - class DrawableComponent : public WAL::Component + class Drawable2DComponent : public WAL::Component { public: T member; - explicit DrawableComponent(WAL::Entity &entity) + explicit Drawable2DComponent(WAL::Entity &entity) : WAL::Component(entity) { } diff --git a/sources/Component/Drawable/Drawable3DComponent.hpp b/sources/Component/Drawable/Drawable3DComponent.hpp new file mode 100644 index 00000000..80814549 --- /dev/null +++ b/sources/Component/Drawable/Drawable3DComponent.hpp @@ -0,0 +1,23 @@ +// +// Created by cbihan on 24/05/2021. +// + +#pragma once + +#include "Component/Component.hpp" +#include "Drawables/ADrawable3D.hpp" + +namespace BBM +{ + template + class Drawable3DComponent : public WAL::Component + { + public: + T member; + + explicit Drawable3DComponent(WAL::Entity &entity) + : WAL::Component(entity) + { + } + }; +} \ No newline at end of file diff --git a/sources/System/Renderer/RendererSystem.hpp b/sources/System/Renderer/Renderer2DSystem.hpp similarity index 56% rename from sources/System/Renderer/RendererSystem.hpp rename to sources/System/Renderer/Renderer2DSystem.hpp index 84f2a655..a0ceea2d 100644 --- a/sources/System/Renderer/RendererSystem.hpp +++ b/sources/System/Renderer/Renderer2DSystem.hpp @@ -8,35 +8,35 @@ #include "System/System.hpp" #include "Entity/Entity.hpp" #include "Component/Position/PositionComponent.hpp" -#include "Component/Drawable/DrawableComponent.hpp" +#include "Component/Drawable/Drawable2DComponent.hpp" #include "Window.hpp" namespace BBM { template - class RendererSystem : public WAL::System + class Renderer2DSystem : public WAL::System { private: //! @brief The class to render RAY::Window &_window; public: - explicit RendererSystem(RAY::Window &window) - : WAL::System({typeid(PositionComponent), typeid(DrawableComponent)}), + explicit Renderer2DSystem(RAY::Window &window) + : WAL::System({typeid(PositionComponent), typeid(Drawable3DComponent)}), _window(window) { } void onUpdate(WAL::Entity &entity, std::chrono::nanoseconds dtime) override { - auto &comp = entity.getComponent>(); + auto &comp = entity.getComponent>(); auto &pos = entity.getComponent(); // TODO update drawable pos with pos comp.member.drawOn(this->_window); } - RendererSystem(const RendererSystem &) = default; - ~RendererSystem() override = default; - RendererSystem &operator=(const RendererSystem &) = delete; + Renderer2DSystem(const Renderer3DSystem &) = default; + ~Renderer2DSystem() override = default; + Renderer2DSystem &operator=(const Renderer2DSystem &) = delete; }; } \ No newline at end of file diff --git a/sources/System/Renderer/Renderer3DSystem.hpp b/sources/System/Renderer/Renderer3DSystem.hpp new file mode 100644 index 00000000..36c49aa4 --- /dev/null +++ b/sources/System/Renderer/Renderer3DSystem.hpp @@ -0,0 +1,42 @@ +// +// Created by cbihan on 24/05/2021. +// + +#pragma once + +#include +#include "System/System.hpp" +#include "Entity/Entity.hpp" +#include "Component/Position/PositionComponent.hpp" +#include "Component/Drawable/Drawable3DComponent.hpp" +#include "Window.hpp" + +namespace BBM +{ + template + class Renderer3DSystem : public WAL::System + { + private: + //! @brief The class to render + RAY::Window &_window; + public: + explicit Renderer3DSystem(RAY::Window &window) + : WAL::System({typeid(PositionComponent), typeid(Drawable3DComponent)}), + _window(window) + { + } + + void onUpdate(WAL::Entity &entity, std::chrono::nanoseconds dtime) override + { + auto &comp = entity.getComponent>(); + auto &pos = entity.getComponent(); + + // TODO update drawable pos with pos + comp.member.drawOn(this->_window); + } + + Renderer3DSystem(const Renderer3DSystem &) = default; + ~Renderer3DSystem() override = default; + Renderer3DSystem &operator=(const Renderer3DSystem &) = delete; + }; +} \ No newline at end of file