big merge and fixing unit test compil

This commit is contained in:
Clément Le Bihan
2021-05-26 11:38:21 +02:00
parent a5a336e1f5
commit 408e955b52
6 changed files with 72 additions and 6 deletions
@@ -0,0 +1,22 @@
//
// Created by Zoe Roux on 5/17/21.
//
#include "MovableComponent.hpp"
namespace BBM
{
MovableComponent::MovableComponent(WAL::Entity &entity)
: Component(entity)
{}
WAL::Component *MovableComponent::clone(WAL::Entity &entity) const
{
return new MovableComponent(entity);
}
void MovableComponent::addForce(Vector3f force)
{
this->_acceleration += force;
}
} // namespace WAL
@@ -14,13 +14,13 @@ namespace BBM
{
private:
//! @brief The acceleration of this entity.
WAL::Vector3f _acceleration;
Vector3f _acceleration;
//! @brief The velocity of the entity.
WAL::Vector3f _velocity;
Vector3f _velocity;
public:
//! @brief Add an instant force to this entity.
//! @param force The force to add to this entity's acceleration. The force is added instantly and in one go.
void addForce(WAL::Vector3f force);
void addForce(Vector3f force);
//! @inherit
WAL::Component *clone(WAL::Entity &entity) const override;
@@ -0,0 +1,43 @@
//
// Created by Zoe Roux on 5/17/21.
//
#include "PositionComponent.hpp"
namespace BBM
{
PositionComponent::PositionComponent(WAL::Entity &entity)
: Component(entity),
position()
{}
PositionComponent::PositionComponent(WAL::Entity &entity, Vector3f pos)
: Component(entity),
position(pos)
{}
PositionComponent::PositionComponent(WAL::Entity &entity, float x, float y, float z)
: Component(entity),
position(x, y, z)
{}
WAL::Component *PositionComponent::clone(WAL::Entity &entity) const
{
return new PositionComponent(entity, this->position);
}
float PositionComponent::getX() const
{
return this->position.x;
}
float PositionComponent::getY() const
{
return this->position.y;
}
float PositionComponent::getZ() const
{
return this->position.z;
}
} // namespace WAL
@@ -14,7 +14,7 @@ namespace BBM
{
public:
//! @brief Get the editable position of this entity
WAL::Vector3f position;
Vector3f position;
//! @brief Get the X position of this entity.
float getX() const;
@@ -29,7 +29,7 @@ namespace BBM
//! @brief Create a new PositionComponent linked to a specific entity
explicit PositionComponent(WAL::Entity &entity);
//! @brief Create a new PositionComponent at a certain position
PositionComponent(WAL::Entity &entity, WAL::Vector3f pos);
PositionComponent(WAL::Entity &entity, Vector3f pos);
//! @brief Create a new PositionComponent at a certain position
PositionComponent(WAL::Entity &entity, float x, float y, float z);
//! @brief A position component is copy constructable
+1 -1
View File
@@ -23,6 +23,6 @@ namespace BBM
position.position += movable._velocity * WAL::Wal::timestep.count();
movable._velocity = movable._acceleration * WAL::Wal::timestep.count();
movable._acceleration = WAL::Vector3f();
movable._acceleration = Vector3f();
}
} // namespace WAL
+1
View File
@@ -24,6 +24,7 @@
#include "Vector/Vector3.hpp"
#include "Window.hpp"
#include "TraceLog.hpp"
#include "Wal.hpp"
const std::vector<std::string>textures = {
"black", "blue", "pink", "red", "white", "yellow"