Files
Bomberman/sources/System/Movable/MovableSystem.cpp
Clément Le Bihan 8c3ef2a23c Merge branch 'develop' into renderer
# Conflicts:
#	lib/wal/sources/Component/Movable/MovableComponent.cpp
#	lib/wal/sources/Component/Position/PositionComponent.cpp
2021-05-25 10:47:35 +02:00

28 lines
716 B
C++

//
// Created by Zoe Roux on 5/17/21.
//
#include "Component/Position/PositionComponent.hpp"
#include "MovableSystem.hpp"
#include "Component/Movable/MovableComponent.hpp"
#include "Wal.hpp"
namespace BBM
{
MovableSystem::MovableSystem()
: WAL::System({
typeid(MovableComponent),
typeid(PositionComponent)
})
{}
void MovableSystem::onFixedUpdate(WAL::Entity &entity)
{
auto &movable = entity.getComponent<MovableComponent>();
auto &position = entity.getComponent<PositionComponent>();
position.position += movable._velocity * WAL::Wal::timestep.count();
movable._velocity = movable._acceleration * WAL::Wal::timestep.count();
movable._acceleration = WAL::Vector3f();
}
} // namespace WAL