From 41d8369ba53338068cd540a23fb3a20e116d53a2 Mon Sep 17 00:00:00 2001 From: "arthur.jamet" Date: Tue, 15 Jun 2021 09:45:57 +0200 Subject: [PATCH] create score component --- CMakeLists.txt | 2 ++ sources/Component/Score/ScoreComponent.cpp | 16 ++++++++++++ sources/Component/Score/ScoreComponent.hpp | 29 ++++++++++++++++++++++ 3 files changed, 47 insertions(+) create mode 100644 sources/Component/Score/ScoreComponent.cpp create mode 100644 sources/Component/Score/ScoreComponent.hpp diff --git a/CMakeLists.txt b/CMakeLists.txt index 64299c95..67b561e9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -130,6 +130,8 @@ set(SOURCES sources/Runner/PauseMenuScene.cpp sources/Runner/SettingsMenuScene.cpp sources/Runner/CreditScene.cpp + sources/Component/Score/ScoreComponent.cpp + sources/Component/Score/ScoreComponent.hpp ) add_executable(bomberman sources/main.cpp diff --git a/sources/Component/Score/ScoreComponent.cpp b/sources/Component/Score/ScoreComponent.cpp new file mode 100644 index 00000000..6fa3d776 --- /dev/null +++ b/sources/Component/Score/ScoreComponent.cpp @@ -0,0 +1,16 @@ + +#include "ScoreComponent.hpp" + +namespace BBM +{ + ScoreComponent::ScoreComponent(WAL::Entity &entity) + : Component(entity), + position() + {} + + WAL::Component *ScoreComponent::clone(WAL::Entity &entity) const + { + return new ScoreComponent(entity); + } + +} // namespace WAL \ No newline at end of file diff --git a/sources/Component/Score/ScoreComponent.hpp b/sources/Component/Score/ScoreComponent.hpp new file mode 100644 index 00000000..f44d0015 --- /dev/null +++ b/sources/Component/Score/ScoreComponent.hpp @@ -0,0 +1,29 @@ + +#pragma once + +#include "Component/Component.hpp" + +namespace BBM +{ + //! @brief A basic position component + class ScoreComponent : public WAL::Component + { + public: + //! @brief score of player (4 is the looser, 1 is the winner) + enum Score {FIRST = 1, SECOND = 2, THIRD = 3, FOURTH = 4, PLAYING = -1}; + //! @brief the score of the player + enum Score position; + + //! @inherit + WAL::Component *clone(WAL::Entity &entity) const override; + + //! @brief Create a new ScoreComponent linked to a specific entity + explicit ScoreComponent(WAL::Entity &entity); + //! @brief A position component is copy constructable + ScoreComponent(const ScoreComponent &) = default; + //! @brief A default destructor + ~ScoreComponent() override = default; + //! @brief A position component is not assignable + ScoreComponent &operator=(const ScoreComponent &) = delete; + }; +} // namespace WAL \ No newline at end of file