blob: 50a8bc8501d7e37d866a31dac675ca8d8de81f3f (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
|
#include "pondering.h"
#include "game.h"
#include "components/ponderable.h"
#include "components/transformable.h"
void PonderingSystem::tick(double dt)
{
auto entities = game.getEntityManager().getEntitiesWithComponents<PonderableComponent, TransformableComponent>();
for (auto entity : entities)
{
auto& transformable = game.getEntityManager().getComponent<TransformableComponent>(entity);
auto& ponderable = game.getEntityManager().getComponent<PonderableComponent>(entity);
// Accelerate
ponderable.setVelocityX(ponderable.getVelocityX() + ponderable.getAccelX() * dt);
ponderable.setVelocityY(ponderable.getVelocityY() + ponderable.getAccelY() * dt);
// Move
transformable.setX(transformable.getX() + ponderable.getVelocityX() * dt);
transformable.setY(transformable.getY() + ponderable.getVelocityY() * dt);
}
}
|