16 lines
642 B
C++
16 lines
642 B
C++
#include "MovementSystem.h"
|
|
#include "components/Direction.h"
|
|
#include "components/Position.h"
|
|
|
|
void MovementSystem::update(entityx::EntityManager &es,
|
|
entityx::EventManager &events,
|
|
entityx::TimeDelta dt)
|
|
{
|
|
for (entityx::Entity entity : es.entities_with_components<Position, Direction>())
|
|
{
|
|
entityx::ComponentHandle<Position> position = entity.component<Position>();
|
|
entityx::ComponentHandle<Direction> direction = entity.component<Direction>();
|
|
position.get()->x += direction.get()->x * dt;
|
|
position.get()->y += direction.get()->y * dt;
|
|
}
|
|
} |