creating a second ctor for Drawable2D

This commit is contained in:
Clément Le Bihan
2021-06-16 17:42:48 +02:00
parent 05806fd2c3
commit 43de339cf7
9 changed files with 58 additions and 50 deletions
@@ -27,6 +27,14 @@ namespace BBM
drawBefore3D(drawBefore3D)
{}
//! ctor
template<typename T, typename ...Params>
explicit Drawable2DComponent(WAL::Entity &entity, WAL::TypeHolder<T>, Params &&...params)
: WAL::Component(entity),
drawable(new T(std::forward<Params>(params)...)),
drawBefore3D(false)
{}
//! ctor
template<typename T, typename ...Params>
explicit Drawable2DComponent(WAL::Entity &entity, WAL::TypeHolder<T>, bool drawBefore3D, Params &&...params)
+7 -7
View File
@@ -26,7 +26,7 @@ namespace BBM
addMenuControl(*scene);
scene->addEntity("background")
.addComponent<PositionComponent>()
.addComponent<Drawable2DComponent, RAY::Texture>(false, "assets/plain_menu_background.png");
.addComponent<Drawable2DComponent, RAY::Texture>("assets/plain_menu_background.png");
scene->addEntity("Control entity")
.addComponent<MusicComponent>("assets/musics/music_title.ogg")
@@ -34,22 +34,22 @@ namespace BBM
auto &raylibLogo = scene->addEntity("raylib logo")
.addComponent<PositionComponent>(1920 / 3.5, 1080 / 1.75, 0)
.addComponent<Drawable2DComponent, RAY::Texture>(false, "assets/raylib.png");
.addComponent<Drawable2DComponent, RAY::Texture>("assets/raylib.png");
auto &raylibText = scene->addEntity("raylib text")
.addComponent<PositionComponent>(1920 / 4, 1080 / 2, 0)
.addComponent<Drawable2DComponent, RAY2D::Text>(false, "Powered by:", 35, RAY::Vector2(), BLACK);
.addComponent<Drawable2DComponent, RAY2D::Text>("Powered by:", 35, RAY::Vector2(), BLACK);
auto &otherRepoText = scene->addEntity("other repo text")
.addComponent<PositionComponent>(1920 / 4, 1080 / 4, 0)
.addComponent<Drawable2DComponent, RAY2D::Text>(false, "Many Thanks to:", 35, RAY::Vector2(), BLACK);
.addComponent<Drawable2DComponent, RAY2D::Text>("Many Thanks to:", 35, RAY::Vector2(), BLACK);
auto &BriansRepo = scene->addEntity("thx brian")
.addComponent<PositionComponent>(1920 / 3.5, 1080 / 3.25, 0)
.addComponent<Drawable2DComponent, RAY2D::Text>(false, "Brian Guitteny (and his team)\nAssets used by their permission", 35, RAY::Vector2(), BLACK);
.addComponent<Drawable2DComponent, RAY2D::Text>("Brian Guitteny (and his team)\nAssets used by their permission", 35, RAY::Vector2(), BLACK);
auto &team = scene->addEntity("team")
.addComponent<PositionComponent>(1920 / 1.5, 1080 / 3.5, 0)
.addComponent<Drawable2DComponent, RAY2D::Text>(false, "Team:\n Zoe Roux\n Clément Le Bihan\n Arthur Jamet\n Louis Auzuret\n Benjamin Henry\n Tom Augier", 35, RAY::Vector2(), BLACK);
.addComponent<Drawable2DComponent, RAY2D::Text>("Team:\n Zoe Roux\n Clément Le Bihan\n Arthur Jamet\n Louis Auzuret\n Benjamin Henry\n Tom Augier", 35, RAY::Vector2(), BLACK);
auto &back = scene->addEntity("back to menu")
.addComponent<PositionComponent>(10, 1080 - 85, 0)
.addComponent<Drawable2DComponent, RAY::Texture>(false, "assets/buttons/button_back.png")
.addComponent<Drawable2DComponent, RAY::Texture>("assets/buttons/button_back.png")
.addComponent<OnClickComponent>([](WAL::Entity &entity, WAL::Wal &)
{
gameState.nextScene = BBM::GameState::SceneID::MainMenuScene;
+10 -10
View File
@@ -39,13 +39,13 @@ namespace BBM
.addComponent<SoundComponent>(sounds);
scene->addEntity("background")
.addComponent<PositionComponent>()
.addComponent<Drawable2DComponent, RAY::Texture>(false, "assets/plain_menu_background.png");
.addComponent<Drawable2DComponent, RAY::Texture>("assets/plain_menu_background.png");
scene->addEntity("lobby text")
.addComponent<PositionComponent>(1920 / 2.75, 100, 0)
.addComponent<Drawable2DComponent, RAY2D::Text>(false, "Get Ready", 120, RAY::Vector2(), ORANGE);
.addComponent<Drawable2DComponent, RAY2D::Text>("Get Ready", 120, RAY::Vector2(), ORANGE);
auto &play = scene->addEntity("play button")
.addComponent<PositionComponent>(1920 / 2.5, 1080 - 180, 0)
.addComponent<Drawable2DComponent, RAY::Texture>(false, "assets/buttons/button_new_game.png")
.addComponent<Drawable2DComponent, RAY::Texture>("assets/buttons/button_new_game.png")
.addComponent<OnIdleComponent>([](WAL::Entity &entity, WAL::Wal &wal)
{
auto *texture = dynamic_cast<RAY::Texture *>(entity.getComponent<Drawable2DComponent>().drawable.get());
@@ -68,7 +68,7 @@ namespace BBM
auto &back = scene->addEntity("back to menu")
.addComponent<PositionComponent>(10, 1080 - 85, 0)
.addComponent<Drawable2DComponent, RAY::Texture>(false, "assets/buttons/button_back.png")
.addComponent<Drawable2DComponent, RAY::Texture>("assets/buttons/button_back.png")
.addComponent<OnClickComponent>([](WAL::Entity &entity, WAL::Wal &wal)
{
gameState.nextScene = BBM::GameState::SceneID::MainMenuScene;
@@ -88,7 +88,7 @@ namespace BBM
});
auto &lavaOption = scene->addEntity("lava option text")
.addComponent<PositionComponent>(1920 / 6, 1.85 * 1080 / 3, 0)
.addComponent<Drawable2DComponent, RAY2D::Text>(false, "Lava: Off", 70, RAY::Vector2(), BLACK)
.addComponent<Drawable2DComponent, RAY2D::Text>("Lava: Off", 70, RAY::Vector2(), BLACK)
.addComponent<OnClickComponent>([](WAL::Entity &entity, WAL::Wal &wal)
{
auto *text = dynamic_cast<RAY2D::Text *>(entity.getComponent<Drawable2DComponent>().drawable.get());
@@ -112,7 +112,7 @@ namespace BBM
auto &heightOption = scene->addEntity("Height option text")
.addComponent<PositionComponent>(1920 / 6, 2.1 * 1080 / 3, 0)
.addComponent<Drawable2DComponent, RAY2D::Text>(false, "2nd Level: Off", 70, RAY::Vector2(), BLACK)
.addComponent<Drawable2DComponent, RAY2D::Text>("2nd Level: Off", 70, RAY::Vector2(), BLACK)
.addComponent<OnClickComponent>([](WAL::Entity &entity, WAL::Wal &wal)
{
auto *text = dynamic_cast<RAY2D::Text *>(entity.getComponent<Drawable2DComponent>().drawable.get());
@@ -136,7 +136,7 @@ namespace BBM
auto &aiMore = scene->addEntity("AI+")
.addComponent<PositionComponent>(1920 / 1.75, 1.85 * 1080 / 3, 0)
.addComponent<Drawable2DComponent, RAY::Texture>(false, "assets/buttons/cpu_add.png")
.addComponent<Drawable2DComponent, RAY::Texture>("assets/buttons/cpu_add.png")
.addComponent<OnClickComponent>([](WAL::Entity &entity, WAL::Wal &wal)
{
wal.getSystem<LobbySystem>().addAI();
@@ -176,11 +176,11 @@ namespace BBM
.addComponent<Drawable2DComponent, RAY2D::Rectangle>(false, RAY::Vector2(224 * (i + 1) + 200 * i, 1080 / 3), RAY::Vector2(200, 200), RAY::Color(0, 0, 0, 0));
auto &player = scene->addEntity("player")
.addComponent<PositionComponent>(224 * (i + 1) + 200 * i, 1080 / 3, 0)
.addComponent<Drawable2DComponent, RAY::Texture>(false, "assets/player/icons/none.png");
.addComponent<Drawable2DComponent, RAY::Texture>("assets/player/icons/none.png");
auto &ready = scene->addEntity("ready")
.addComponent<PositionComponent>(224 * (i + 1) + 200 * i, 1080 / 3, 0)
// todo check why it does this | hacky way to fix ready texture
.addComponent<Drawable2DComponent, RAY::Texture>(false, "");
// todo check why it does this | hacky way to fix ready texture
.addComponent<Drawable2DComponent, RAY::Texture>("");
player.addComponent<LobbyComponent>(i, ready, playerTile);
}
scene->addEntity("camera")
+5 -5
View File
@@ -29,13 +29,13 @@ namespace BBM
.addComponent<SoundComponent>(sounds);
scene->addEntity("background")
.addComponent<PositionComponent>()
.addComponent<Drawable2DComponent, RAY::Texture>(false, "assets/plain_menu_background.png");
.addComponent<Drawable2DComponent, RAY::Texture>("assets/plain_menu_background.png");
scene->addEntity("logo")
.addComponent<PositionComponent>(1920 / 3, 180, 0)
.addComponent<Drawable2DComponent, RAY::Texture>(false, "assets/logo_small.png");
.addComponent<Drawable2DComponent, RAY::Texture>("assets/logo_small.png");
auto &play = scene->addEntity("play button")
.addComponent<PositionComponent>(1920 / 2.5, 1080 - 540, 0)
.addComponent<Drawable2DComponent, RAY::Texture>(false, "assets/buttons/button_new_game.png")
.addComponent<Drawable2DComponent, RAY::Texture>("assets/buttons/button_new_game.png")
.addComponent<OnIdleComponent>([](WAL::Entity &entity, WAL::Wal &)
{
RAY::Texture *texture = dynamic_cast<RAY::Texture *>(entity.getComponent<Drawable2DComponent>().drawable.get());
@@ -54,7 +54,7 @@ namespace BBM
});
auto &settings = scene->addEntity("settings button")
.addComponent<PositionComponent>(1920 / 2.5, 1080 - 360, 0)
.addComponent<Drawable2DComponent, RAY::Texture>(false, "assets/buttons/button_settings.png")
.addComponent<Drawable2DComponent, RAY::Texture>("assets/buttons/button_settings.png")
.addComponent<OnIdleComponent>([](WAL::Entity &entity, WAL::Wal &)
{
RAY::Texture *texture = dynamic_cast<RAY::Texture *>(entity.getComponent<Drawable2DComponent>().drawable.get());
@@ -92,7 +92,7 @@ namespace BBM
});
auto &credits = scene->addEntity("credit button")
.addComponent<PositionComponent>(1920 - 100, 1080 - 30, 0)
.addComponent<Drawable2DComponent, RAY2D::Text>(false, "Credits", 20, RAY::Vector2(), BLACK)
.addComponent<Drawable2DComponent, RAY2D::Text>("Credits", 20, RAY::Vector2(), BLACK)
.addComponent<OnIdleComponent>([](WAL::Entity &entity, WAL::Wal &)
{
RAY2D::Text *text = dynamic_cast<RAY2D::Text *>(entity.getComponent<Drawable2DComponent>().drawable.get());
+5 -5
View File
@@ -29,13 +29,13 @@ namespace BBM
.addComponent<SoundComponent>(sounds);
scene->addEntity("background")
.addComponent<PositionComponent>()
.addComponent<Drawable2DComponent, RAY::Texture>(false, "assets/plain_menu_background.png");
.addComponent<Drawable2DComponent, RAY::Texture>("assets/plain_menu_background.png");
scene->addEntity("pause text")
.addComponent<PositionComponent>(1920 / 2.5, 180, 0)
.addComponent<Drawable2DComponent, RAY2D::Text>(false, "PAUSE", 120, RAY::Vector2(), ORANGE);
.addComponent<Drawable2DComponent, RAY2D::Text>("PAUSE", 120, RAY::Vector2(), ORANGE);
auto &play = scene->addEntity("play button")
.addComponent<PositionComponent>(1920 / 6.5, 1080 - 360, 0)
.addComponent<Drawable2DComponent, RAY::Texture>(false, "assets/buttons/button_back.png")
.addComponent<Drawable2DComponent, RAY::Texture>("assets/buttons/button_back.png")
.addComponent<OnIdleComponent>([](WAL::Entity &entity, WAL::Wal &)
{
RAY::Texture *texture = dynamic_cast<RAY::Texture *>(entity.getComponent<Drawable2DComponent>().drawable.get());
@@ -54,7 +54,7 @@ namespace BBM
});
auto &settings = scene->addEntity("settings button")
.addComponent<PositionComponent>(1920 / 2.5, 1080 - 360, 0)
.addComponent<Drawable2DComponent, RAY::Texture>(false, "assets/buttons/button_settings.png")
.addComponent<Drawable2DComponent, RAY::Texture>("assets/buttons/button_settings.png")
.addComponent<OnIdleComponent>([](WAL::Entity &entity, WAL::Wal &)
{
RAY::Texture *texture = dynamic_cast<RAY::Texture *>(entity.getComponent<Drawable2DComponent>().drawable.get());
@@ -73,7 +73,7 @@ namespace BBM
});
auto &exit = scene->addEntity("exit button")
.addComponent<PositionComponent>(1920 / 1.5, 1080 - 360, 0)
.addComponent<Drawable2DComponent, RAY::Texture>(false, "assets/buttons/button_exit.png")
.addComponent<Drawable2DComponent, RAY::Texture>("assets/buttons/button_exit.png")
.addComponent<OnIdleComponent>([](WAL::Entity &entity, WAL::Wal &)
{
RAY::Texture *texture = dynamic_cast<RAY::Texture *>(entity.getComponent<Drawable2DComponent>().drawable.get());
+7 -7
View File
@@ -51,30 +51,30 @@ namespace BBM
.addComponent<SoundComponent>(sounds);
scene->addEntity("background")
.addComponent<PositionComponent>()
.addComponent<Drawable2DComponent, RAY::Texture>(false, "assets/plain_menu_background.png");
.addComponent<Drawable2DComponent, RAY::Texture>("assets/plain_menu_background.png");
scene->addEntity("scene title text")
.addComponent<PositionComponent>(1920 / 3.25, 100, 0)
.addComponent<Drawable2DComponent, RAY2D::Text>(false, "GAME OVER", 120, RAY::Vector2(), ORANGE);
.addComponent<Drawable2DComponent, RAY2D::Text>("GAME OVER", 120, RAY::Vector2(), ORANGE);
scene->addEntity("scene title text")
.addComponent<PositionComponent>(1920 / 2.37, 250, 0)
.addComponent<Drawable2DComponent, RAY2D::Text>(false, "CONGRATS", 50, RAY::Vector2(), ORANGE);
.addComponent<Drawable2DComponent, RAY2D::Text>("CONGRATS", 50, RAY::Vector2(), ORANGE);
for (int i = 0; i < players.size(); i++) {
auto &playerTile = scene->addEntity("player tile")
.addComponent<PositionComponent>(224 * (i + 1) + 200 * i, 1080 / 2.5, 0)
.addComponent<Drawable2DComponent, RAY2D::Rectangle>(false, RAY::Vector2(224 * (i + 1) + 200 * i, 1080 / 3),
.addComponent<Drawable2DComponent, RAY2D::Rectangle>(RAY::Vector2(224 * (i + 1) + 200 * i, 1080 / 3),
RAY::Vector2(200, 200), tilesColor[i]);
auto &playerRank = scene->addEntity("player rank name")
.addComponent<PositionComponent>(224 * (i + 1) + 200 * i, 1080 / 2.75, 0)
.addComponent<Drawable2DComponent, RAY2D::Text>(false, rankName[i], 30,
.addComponent<Drawable2DComponent, RAY2D::Text>(rankName[i], 30,
RAY::Vector2(224 * (i + 1) + 200 * i, 1080 / 3),
tilesColor[i]);
auto &player = scene->addEntity("player")
.addComponent<PositionComponent>(224 * (i + 1) + 200 * i, 1080 / 2.5, 0)
.addComponent<Drawable2DComponent, RAY::Texture>(false, playersIconPath[i]);
.addComponent<Drawable2DComponent, RAY::Texture>(playersIconPath[i]);
}
scene->addEntity("back to main menu")
.addComponent<PositionComponent>(10, 1080 - 85, 0)
.addComponent<Drawable2DComponent, RAY::Texture>(false, "assets/buttons/button_back.png")
.addComponent<Drawable2DComponent, RAY::Texture>("assets/buttons/button_back.png")
.addComponent<OnClickComponent>([](WAL::Entity &entity, WAL::Wal &) {
gameState.nextScene = BBM::GameState::SceneID::MainMenuScene;
})
+10 -10
View File
@@ -30,13 +30,13 @@ namespace BBM
.addComponent<SoundComponent>(sounds);
scene->addEntity("background")
.addComponent<PositionComponent>()
.addComponent<Drawable2DComponent, RAY::Texture>(false, "assets/plain_menu_background.png");
.addComponent<Drawable2DComponent, RAY::Texture>("assets/plain_menu_background.png");
scene->addEntity("logo")
.addComponent<PositionComponent>(1920 / 3, 180, 0)
.addComponent<Drawable2DComponent, RAY::Texture>(false, "assets/logo_small.png");
.addComponent<Drawable2DComponent, RAY::Texture>("assets/logo_small.png");
auto &music = scene->addEntity("music text")
.addComponent<PositionComponent>(1920 / 2.5, 1080 - 540, 0)
.addComponent<Drawable2DComponent, RAY2D::Text>(false, "Music Volume", 70, RAY::Vector2(), BLACK)
.addComponent<Drawable2DComponent, RAY2D::Text>("Music Volume", 70, RAY::Vector2(), BLACK)
.addComponent<OnClickComponent>()
.addComponent<OnIdleComponent>([](WAL::Entity &entity, WAL::Wal &)
{
@@ -49,7 +49,7 @@ namespace BBM
auto &musicUp = scene->addEntity("music up button")
.addComponent<PositionComponent>(1920 / 1.5, 1080 - 540, 0)
.addComponent<Drawable2DComponent, RAY::Texture>(false, "assets/buttons/button_plus.png")
.addComponent<Drawable2DComponent, RAY::Texture>("assets/buttons/button_plus.png")
.addComponent<MusicComponent>("assets/musics/music_title.ogg")
.addComponent<OnIdleComponent>([](WAL::Entity &entity, WAL::Wal &)
{
@@ -72,7 +72,7 @@ namespace BBM
auto &musicDown = scene->addEntity("music down button")
.addComponent<PositionComponent>(1920 / 3, 1080 - 540, 0)
.addComponent<Drawable2DComponent, RAY::Texture>(false, "assets/buttons/button_minus.png")
.addComponent<Drawable2DComponent, RAY::Texture>("assets/buttons/button_minus.png")
.addComponent<MusicComponent>("assets/musics/music_title.ogg")
.addComponent<OnIdleComponent>([](WAL::Entity &entity, WAL::Wal &)
{
@@ -95,7 +95,7 @@ namespace BBM
auto &sound = scene->addEntity("sound text")
.addComponent<PositionComponent>(1920 / 2.5, 1080 - 360, 0)
.addComponent<Drawable2DComponent, RAY2D::Text>(false, "Sound Volume", 70, RAY::Vector2(), BLACK)
.addComponent<Drawable2DComponent, RAY2D::Text>("Sound Volume", 70, RAY::Vector2(), BLACK)
.addComponent<OnClickComponent>()
.addComponent<OnIdleComponent>([](WAL::Entity &entity, WAL::Wal &)
{
@@ -108,7 +108,7 @@ namespace BBM
auto &soundUp = scene->addEntity("sound up button")
.addComponent<PositionComponent>(1920 / 1.5, 1080 - 360, 0)
.addComponent<Drawable2DComponent, RAY::Texture>(false, "assets/buttons/button_plus.png")
.addComponent<Drawable2DComponent, RAY::Texture>("assets/buttons/button_plus.png")
.addComponent<SoundComponent>(sounds)
.addComponent<OnClickComponent>([](WAL::Entity &entity, WAL::Wal &)
{
@@ -131,7 +131,7 @@ namespace BBM
auto &soundDown = scene->addEntity("sound down button")
.addComponent<PositionComponent>(1920 / 3, 1080 - 360, 0)
.addComponent<Drawable2DComponent, RAY::Texture>(false, "assets/buttons/button_minus.png")
.addComponent<Drawable2DComponent, RAY::Texture>("assets/buttons/button_minus.png")
.addComponent<SoundComponent>(sounds)
.addComponent<OnIdleComponent>([](WAL::Entity &entity, WAL::Wal &)
{
@@ -154,7 +154,7 @@ namespace BBM
auto &debug = scene->addEntity("debug text")
.addComponent<PositionComponent>(1920 / 2.5, 1080 - 180, 0)
.addComponent<Drawable2DComponent, RAY2D::Text>(false, "Debug Mode: Off", 70, RAY::Vector2(), BLACK)
.addComponent<Drawable2DComponent, RAY2D::Text>("Debug Mode: Off", 70, RAY::Vector2(), BLACK)
.addComponent<OnClickComponent>([](WAL::Entity &entity, WAL::Wal &wal)
{
RAY2D::Text *text = dynamic_cast<RAY2D::Text *>(entity.getComponent<Drawable2DComponent>().drawable.get());
@@ -177,7 +177,7 @@ namespace BBM
});
auto &back = scene->addEntity("back to menu")
.addComponent<PositionComponent>(10, 1080 - 85, 0)
.addComponent<Drawable2DComponent, RAY::Texture>(false, "assets/buttons/button_back.png")
.addComponent<Drawable2DComponent, RAY::Texture>("assets/buttons/button_back.png")
.addComponent<OnClickComponent>([](WAL::Entity &entity, WAL::Wal &)
{
gameState.nextScene = BBM::GameState::SceneID::MainMenuScene;
+3 -3
View File
@@ -24,13 +24,13 @@ namespace BBM
.addComponent<IntroAnimationComponent>();
auto &background = scene->addEntity("background")
.addComponent<PositionComponent>(0, 0, 0)
.addComponent<Drawable2DComponent, RAY2D::Rectangle>(false, RAY::Vector2(), RAY::Vector2(1920, 1080));
.addComponent<Drawable2DComponent, RAY2D::Rectangle>(RAY::Vector2(), RAY::Vector2(1920, 1080));
auto &text = scene->addEntity("powered by text")
.addComponent<PositionComponent>(1920 / 2 - 200, 1080 / 2 - 180, 0)
.addComponent<Drawable2DComponent, RAY2D::Text>(false, "powered by", 30, RAY::Vector2(), BLACK);
.addComponent<Drawable2DComponent, RAY2D::Text>("powered by", 30, RAY::Vector2(), BLACK);
auto &skipText = scene->addEntity("Press space to skip")
.addComponent<PositionComponent>(1920 - 250, 1080 - 30, 0)
.addComponent<Drawable2DComponent, RAY2D::Text>(false, "Press space to skip", 20, RAY::Vector2(), BLACK);
.addComponent<Drawable2DComponent, RAY2D::Text>("Press space to skip", 20, RAY::Vector2(), BLACK);
return scene;
}
}
+3 -3
View File
@@ -28,13 +28,13 @@ namespace BBM
.addComponent<MusicComponent>("assets/musics/music_title.ogg");
scene->addEntity("background")
.addComponent<PositionComponent>()
.addComponent<Drawable2DComponent, RAY::Texture>(false, "assets/plain_menu_background.png");
.addComponent<Drawable2DComponent, RAY::Texture>("assets/plain_menu_background.png");
scene->addEntity("logo")
.addComponent<PositionComponent>(320, 180, 0)
.addComponent<Drawable2DComponent, RAY::Texture>(false, "assets/logo_big.png");
.addComponent<Drawable2DComponent, RAY::Texture>("assets/logo_big.png");
scene->addEntity("text_prompt")
.addComponent<PositionComponent>(1920 / 2.5, 1080 - 130, 0)
.addComponent<Drawable2DComponent, RAY2D::Text>(false, "Press space", 70, RAY::Vector2(), BLACK)
.addComponent<Drawable2DComponent, RAY2D::Text>("Press space", 70, RAY::Vector2(), BLACK)
.addComponent<OnIdleComponent>()
.addComponent<OnHoverComponent>()
.addComponent<OnClickComponent>([](WAL::Entity &entity, WAL::Wal &)