Modification on Controllable and Keyboard

Add float variable instead of bool for the axes movement, and use of a map for classic keys

Co-Authored-By: Benjamin HENRY <44569175+EternalRat@users.noreply.github.com>
This commit is contained in:
TrueBabyChaise
2021-05-21 14:17:37 +02:00
parent 61e04f760a
commit 54cb40aa0b
4 changed files with 22 additions and 29 deletions
@@ -17,18 +17,9 @@ namespace BBM
void ControllableSystem::onFixedUpdate(WAL::Entity &entity)
{
auto &controllable= entity.getComponent<ControllableComponent>();
auto &movable= entity.getComponent<WAL::MovableComponent>();
auto &controllable = entity.getComponent<ControllableComponent>();
auto &movable = entity.getComponent<WAL::MovableComponent>();
if (controllable._left)
movable.addForce(WAL::Vector3f(-1, 0, 0));
if (controllable._right)
movable.addForce(WAL::Vector3f(1, 0, 0));
if (controllable._down)
movable.addForce(WAL::Vector3f(0, 0, -1));
if (controllable._up)
movable.addForce(WAL::Vector3f(0, 0, 1));
if (controllable._jump)
movable.addForce(WAL::Vector3f(0, 1, 0));
movable.addForce(WAL::Vector3f(controllable._moveX, 0, controllable._moveZ));
}
}