basic gravity

This commit is contained in:
Askou
2021-06-09 17:23:55 +02:00
parent 63ca018edf
commit d17a410a65
6 changed files with 106 additions and 0 deletions

View File

@@ -0,0 +1,21 @@
//
// Created by Tom Augier on 2021-06-09.
//
#include "GravitySystem.hpp"
namespace BBM
{
GravitySystem::GravitySystem(WAL::Wal &wal)
: System(wal)
{}
void GravitySystem::onFixedUpdate(WAL::ViewEntity<GravityComponent, MovableComponent, PositionComponent> &entity)
{
auto &movable = entity.get<MovableComponent>();
auto &position = entity.get<PositionComponent>();
if (position.getY() > 0)
movable.addForce(Vector3f(0, -0.5, 0));
}
}