9 const std::shared_ptr<eng::IAudio> &audio)
10 : AScene(assignedId), m_renderer(renderer), m_audio(audio)
12 auto ®istry = AScene::getRegistry();
14 registry.onComponentAdded(
15 [&renderer, ®istry, &audio](
const ecs::Entity e,
const std::type_info &type)
17 const auto *audioComp = registry.getComponent<
ecs::Audio>(e);
18 const auto *colorComp = registry.getComponent<
ecs::Color>(e);
19 const auto *scaleComp = registry.getComponent<
ecs::Scale>(e);
20 const auto *textureComp = registry.getComponent<
ecs::Texture>(e);
22 const auto *rectComp = registry.getComponent<
ecs::Rect>(e);
26 const float scale_x = scaleComp ? scaleComp->x : 1.F;
27 const float scale_y = scaleComp ? scaleComp->y : 1.F;
29 renderer->createTexture(textureComp->
id, textureComp->path);
31 if (transform && textureComp)
35 renderer->createSprite(textureComp->
id + std::to_string(e), textureComp->
id, transform->x,
36 transform->y, scale_x, scale_y,
static_cast<int>(rectComp->pos_x),
37 static_cast<int>(rectComp->pos_y), rectComp->size_x, rectComp->size_y);
41 renderer->createSprite(textureComp->
id + std::to_string(e), textureComp->
id, transform->x,
50 audio->createAudio(audioComp->path, audioComp->volume, audioComp->loop,
51 audioComp->id + std::to_string(e));
57 registry.createEntity().with<
ecs::Audio>(
"game_begin",
"assets/audio/elephant.mp3", 20.0F,
false,
true).build();
59 auto [width, height] = renderer->getWindowSize();
61 .with<
ecs::Transform>(
"logo_transform", width * 0.37F, height * 0.2F)
62 .with<ecs::Scale>(
"logo_scale", 1.5F, 1.5F)