lib.cpp 457 B

12345678910111213141516
  1. #include <entt/core/attribute.h>
  2. #include <entt/entity/registry.hpp>
  3. #include "types.h"
  4. ENTT_API void update_position(entt::registry &registry) {
  5. registry.view<position, velocity>().each([](auto &pos, auto &vel) {
  6. pos.x += 16 * vel.dx;
  7. pos.y += 16 * vel.dy;
  8. });
  9. }
  10. ENTT_API void assign_velocity(entt::registry &registry) {
  11. for(auto entity: registry.view<position>()) {
  12. registry.assign<velocity>(entity, 1., 1.);
  13. }
  14. }