test: rework lib stuff to share common files

This commit is contained in:
Michele Caini
2023-01-18 10:17:54 +01:00
parent a3d9503a17
commit f94de1c069
34 changed files with 28 additions and 24 deletions

View File

@@ -0,0 +1,19 @@
#include <entt/core/attribute.h>
#include <entt/entity/registry.hpp>
#include "types.h"
ENTT_API void update_position(entt::registry &registry) {
registry.view<position, velocity>().each([](auto &pos, auto &vel) {
pos.x += static_cast<int>(16 * vel.dx);
pos.y += static_cast<int>(16 * vel.dy);
});
}
ENTT_API void emplace_velocity(entt::registry &registry) {
// forces the creation of the pool for the velocity component
static_cast<void>(registry.storage<velocity>());
for(auto entity: registry.view<position>()) {
registry.emplace<velocity>(entity, 1., 1.);
}
}