movement_system.cpp 626 B

12345678910111213141516171819
  1. #include <application/context.h>
  2. #include <component/position_component.h>
  3. #include <component/velocity_component.h>
  4. #include <entt/entity/registry.hpp>
  5. #include <system/movement_system.h>
  6. namespace testbed {
  7. void movement_system(entt::registry &registry, const context &ctx, const double delta) {
  8. int width{};
  9. int height{};
  10. for(auto [entity, position, velocity]: registry.view<position_component, velocity_component>().each()) {
  11. position.x += (velocity.dx * delta) * (ctx.logical_width() / 10.);
  12. position.y += velocity.dy * delta * (ctx.logical_height() / 10.);
  13. }
  14. }
  15. } // namespace testbed