fixed some warning + one test

This commit is contained in:
HENRY Benjamin
2021-06-18 16:25:38 +02:00
parent 74f85373ac
commit 3c0d933b83
5 changed files with 13 additions and 30 deletions
@@ -6,16 +6,16 @@
namespace BBM
{
ResumeLobbyComponent::ResumeLobbyComponent(WAL::Entity &entity, int playerNumber, WAL::Entity &button, WAL::Entity &tile, int color)
ResumeLobbyComponent::ResumeLobbyComponent(WAL::Entity &entity, int playerNumber, WAL::Entity &button, WAL::Entity &tile, int pColor)
: WAL::Component(entity),
playerID(playerNumber),
readyButton(button),
coloredTile(tile),
color(color)
playerColor(pColor)
{}
WAL::Component *ResumeLobbyComponent::clone(WAL::Entity &entity) const
{
return new ResumeLobbyComponent(entity, this->playerID, this->readyButton, this->coloredTile, this->color);
return new ResumeLobbyComponent(entity, this->playerID, this->readyButton, this->coloredTile, this->playerColor);
}
}
@@ -20,7 +20,7 @@ namespace BBM
//! @brief The ID of the lobby player (from 0 to 3)
int playerID;
//! @brief The color of the player (as an index)
int color;
int playerColor;
//! @brief Is this player ready
bool ready = false;
//! @brief The entity containing the ready display.
@@ -33,7 +33,7 @@ namespace BBM
Component *clone(WAL::Entity &entity) const override;
//! @brief Create a new lobby component.
explicit ResumeLobbyComponent(WAL::Entity &entity, int playerNumber, WAL::Entity &button, WAL::Entity &tile, int color);
explicit ResumeLobbyComponent(WAL::Entity &entity, int playerNumber, WAL::Entity &button, WAL::Entity &tile, int pColor);
//! @brief A lobby component is copyable.
ResumeLobbyComponent(const ResumeLobbyComponent &) = default;
//! @brief A default destructor
+1 -20
View File
@@ -87,29 +87,10 @@ namespace BBM
texture->use("assets/buttons/button_back_hovered.png");
});
auto &howToPlay = scene->addEntity("to to play")
.addComponent<PositionComponent>(1920 - 10 - 75, 1080 - 85, 0)
.addComponent<Drawable2DComponent, RAY::Texture>("assets/buttons/button_htp.png")
.addComponent<OnClickComponent>([](WAL::Entity &entity, WAL::Wal &)
{
gameState.nextScene = BBM::GameState::SceneID::HowToPlayScene;
})
.addComponent<OnIdleComponent>([](WAL::Entity &entity, WAL::Wal &)
{
RAY::Texture *texture = dynamic_cast<RAY::Texture *>(entity.getComponent<Drawable2DComponent>().drawable.get());
texture->use("assets/buttons/button_htp.png");
})
.addComponent<OnHoverComponent>([](WAL::Entity &entity, WAL::Wal &)
{
RAY::Texture *texture = dynamic_cast<RAY::Texture *>(entity.getComponent<Drawable2DComponent>().drawable.get());
texture->use("assets/buttons/button_htp_hovered.png");
});
scene->addEntity("camera")
.addComponent<PositionComponent>(8, 20, 7)
.addComponent<CameraComponent>(Vector3f(8, 0, 8));
play.getComponent<OnClickComponent>().setButtonLinks(nullptr, &back, &back, nullptr);
play.getComponent<OnClickComponent>().setButtonLinks(nullptr, &back, &back);
back.getComponent<OnClickComponent>().setButtonLinks(&play, nullptr, nullptr, &play);
return scene;
}
+5 -5
View File
@@ -150,12 +150,12 @@ namespace BBM
speed->speed = ParserYAML::playersInfos[countPlayer].speed;
}
addController(player, lobby.layout);
std::string texturePath = "assets/player/ui/" + _colors[lobby.color] + ".png";
std::string texturePath = "assets/player/ui/" + _colors[lobby.playerColor] + ".png";
int x = (countPlayer % 2 == 0) ? 1920 - 10 - 320 : 10;
int y = (countPlayer % 3 != 0) ? 1080 - 10 - 248 : 10;
scene->addEntity("player color tile")
.addComponent<PositionComponent>(x, y - 2, 0)
.addComponent<Drawable2DComponent, RAY2D::Rectangle>(x, y, 320, 248, _rayColors[lobby.color]);
.addComponent<Drawable2DComponent, RAY2D::Rectangle>(x, y, 320, 248, _rayColors[lobby.playerColor]);
scene->addEntity("player ui tile")
.addComponent<PositionComponent>(x, y, 0)
.addComponent<Drawable2DComponent, RAY::Texture>(texturePath);
@@ -189,14 +189,14 @@ namespace BBM
.addComponent<PositionComponent>(x + 220, y + 122, 0)
.addComponent<Drawable2DComponent, RAY2D::Text>("", 20, x, y, WHITE)
.addComponent<StatComponent>([&player](Drawable2DComponent &drawble) {
auto *speed = player.tryGetComponent<SpeedComponent>();
auto speedComponent = player.tryGetComponent<SpeedComponent>();
if (!speed)
if (!speedComponent)
return;
RAY2D::Text *text = dynamic_cast<RAY2D::Text *>(drawble.drawable.get());
if (!text)
return;
text->setText(std::to_string(static_cast<int>(speed->speed * 100)));
text->setText(std::to_string(static_cast<int>(speedComponent->speed * 100)));
});
scene->addEntity("player hide wall")
.addComponent<PositionComponent>(x + 220, y + 161, 0)
+2
View File
@@ -12,6 +12,7 @@
#include "System/Movable/MovableSystem.hpp"
#include <Component/Controllable/ControllableComponent.hpp>
#include <Component/Movable/MovableComponent.hpp>
#include <Component/Speed/SpeedComponent.hpp>
using namespace WAL;
using namespace BBM;
@@ -24,6 +25,7 @@ TEST_CASE("Move test", "[Component][System]")
wal.getScene()->addEntity("player")
.addComponent<ControllableComponent>()
.addComponent<MovableComponent>()
.addComponent<SpeedComponent>()
.addComponent<PositionComponent>();
Entity &entity = wal.getScene()->getEntities().front();