15 lines
504 B
C++
15 lines
504 B
C++
// src\movement.cpp
|
|
#include <entt/entt.hpp>
|
|
#include <components.hpp>
|
|
|
|
void update_movement_system(entt::registry& registry, float dt) {
|
|
// We get Position and Velocity, but EXCLUDE entities that have the Player tag
|
|
auto view = registry.view<Position, Velocity>();
|
|
|
|
view.each([dt](Position &position, Velocity &velocity) {
|
|
// This will only run for pipes, enemies, or particles!
|
|
position.x += velocity.dx * dt;
|
|
position.y += velocity.dy * dt;
|
|
});
|
|
}
|