fix: scene manager rendering

This commit is contained in:
illyum 2024-09-11 21:45:57 -06:00
parent 72496226d8
commit 7f32a1d51b

View File

@ -26,14 +26,30 @@ public:
void UpdateActiveScene() {
if (activeScene != entt::null) {
// Iterate over entities in the active scene that have an InputComponent
auto view = registry.view<InputComponent>();
for (auto entity : view) {
auto& inputComponent = view.get<InputComponent>(entity);
inputComponent.Update(); // This will call the input logic
}
}
}
void RenderActiveScene() {
if (activeScene != entt::null) {
// Iterate over entities in the active scene that have both SpriteComponent and TransformComponent
auto view = registry.view<SpriteComponent, TransformComponent>();
for (auto entity : view) {
auto& sprite = view.get<SpriteComponent>(entity);
auto& transform = view.get<TransformComponent>(entity);
// Render the sprite at the position defined by the TransformComponent
sprite.Render(transform);
}
}
}
private:
entt::registry& registry;
entt::entity activeScene;