Adding a grid centered component

This commit is contained in:
Zoe Roux
2021-05-24 18:08:50 +02:00
parent 199b286978
commit 384e812c19
5 changed files with 74 additions and 2 deletions
+4 -2
View File
@@ -36,12 +36,14 @@ set(SOURCES
sources/System/Movable/MovableSystem.cpp sources/System/Movable/MovableSystem.cpp
sources/System/Movable/MovableSystem.hpp sources/System/Movable/MovableSystem.hpp
sources/Models/Vector3.hpp sources/Models/Vector3.hpp
) sources/Component/GridCentered/GridCenteredComponent.cpp
sources/Component/GridCentered/GridCenteredComponent.hpp
sources/System/GridCentered/GridCenteredSystem.cpp sources/System/GridCentered/GridCenteredSystem.hpp)
add_executable(bomberman add_executable(bomberman
sources/main.cpp sources/main.cpp
${SOURCES} ${SOURCES}
sources/Component/Controllable/ControllableComponent.cpp) )
target_include_directories(bomberman PUBLIC sources) target_include_directories(bomberman PUBLIC sources)
target_link_libraries(bomberman PUBLIC wal ray) target_link_libraries(bomberman PUBLIC wal ray)
@@ -0,0 +1,17 @@
//
// Created by Zoe Roux on 5/24/21.
//
#include "GridCenteredComponent.hpp"
namespace BBM
{
GridCenteredComponent::GridCenteredComponent(WAL::Entity &entity)
: WAL::Component(entity)
{}
WAL::Component *GridCenteredComponent::clone(WAL::Entity &entity) const
{
return new GridCenteredComponent(entity);
}
}
@@ -0,0 +1,33 @@
//
// Created by Zoe Roux on 5/24/21.
//
#pragma once
#include <Component/Component.hpp>
namespace BBM
{
//! @brief A component to slowly center entities to the middle of their current block.
//! This allow flexibility in their movement will preventing them from getting stuck at every corner.
class GridCenteredComponent : public WAL::Component
{
public:
//! @brief The force factor applied at each frame.
float force = 1;
//! @inherit
Component *clone(WAL::Entity &entity) const override;
//! @brief Create a new, default GridCenteredComponent.
//! @param entity The entity attached to this component.
explicit GridCenteredComponent(WAL::Entity &entity);
//! @brief A GridCenteredComponent is copy constructable
//! @param other The other GridCenteredComponent to copy.
GridCenteredComponent(const GridCenteredComponent &other) = default;
//! @brief A default destructor
~GridCenteredComponent() override = default;
//! @brief A GridCenteredComponent is not assignable
GridCenteredComponent &operator=(const GridCenteredComponent &) = delete;
};
}
@@ -0,0 +1,5 @@
//
// Created by Zoe Roux on 5/24/21.
//
#include "GridCenteredSystem.hpp"
@@ -0,0 +1,15 @@
//
// Created by Zoe Roux on 5/24/21.
//
#pragma once
#include <System/System.hpp>
namespace BBM
{
class GridCenteredSystem : public WAL::System
{
};
}