Allowing players to join the lobby
|
Before Width: | Height: | Size: 19 KiB After Width: | Height: | Size: 19 KiB |
BIN
assets/player/icons/blue.png
Normal file
|
After Width: | Height: | Size: 16 KiB |
BIN
assets/player/icons/green.png
Normal file
|
After Width: | Height: | Size: 19 KiB |
|
Before Width: | Height: | Size: 2.1 KiB After Width: | Height: | Size: 2.1 KiB |
BIN
assets/player/icons/red.png
Normal file
|
After Width: | Height: | Size: 20 KiB |
BIN
assets/player/icons/yellow.png
Normal file
|
After Width: | Height: | Size: 18 KiB |
|
Before Width: | Height: | Size: 324 B After Width: | Height: | Size: 324 B |
|
Before Width: | Height: | Size: 396 B After Width: | Height: | Size: 396 B |
|
Before Width: | Height: | Size: 333 B After Width: | Height: | Size: 333 B |
|
Before Width: | Height: | Size: 345 B After Width: | Height: | Size: 345 B |
|
Before Width: | Height: | Size: 333 B After Width: | Height: | Size: 333 B |
|
Before Width: | Height: | Size: 333 B After Width: | Height: | Size: 333 B |
|
Before Width: | Height: | Size: 6.0 KiB |
@@ -61,14 +61,20 @@ namespace WAL
|
|||||||
std::optional<ViewEntity<Components...>> _entity;
|
std::optional<ViewEntity<Components...>> _entity;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
ViewEntity<Components...> &operator*()
|
using iterator_category = std::forward_iterator_tag;
|
||||||
|
using difference_type = std::ptrdiff_t;
|
||||||
|
using value_type = ViewEntity<Components...>;
|
||||||
|
using pointer = value_type *;
|
||||||
|
using reference = value_type &;
|
||||||
|
|
||||||
|
reference operator*()
|
||||||
{
|
{
|
||||||
if (!this->_entity)
|
if (!this->_entity)
|
||||||
this->_entity.emplace(*this->_it);
|
this->_entity.emplace(*this->_it);
|
||||||
return *this->_entity;
|
return *this->_entity;
|
||||||
}
|
}
|
||||||
|
|
||||||
ViewEntity<Components...> *operator->()
|
pointer operator->()
|
||||||
{
|
{
|
||||||
if (!this->_entity)
|
if (!this->_entity)
|
||||||
this->_entity =(*this->_it);
|
this->_entity =(*this->_it);
|
||||||
|
|||||||
@@ -3,6 +3,7 @@
|
|||||||
// Edited by Benjamin Henry on 2021-05-20.
|
// Edited by Benjamin Henry on 2021-05-20.
|
||||||
//
|
//
|
||||||
|
|
||||||
|
#include <Component/Controllable/ControllableComponent.hpp>
|
||||||
#include "GamepadComponent.hpp"
|
#include "GamepadComponent.hpp"
|
||||||
|
|
||||||
namespace BBM
|
namespace BBM
|
||||||
@@ -31,4 +32,27 @@ namespace BBM
|
|||||||
return this->_ID;
|
return this->_ID;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void GamepadComponent::onStart()
|
||||||
|
{
|
||||||
|
auto *controller = this->_entity.tryGetComponent<ControllableComponent>();
|
||||||
|
if (!controller)
|
||||||
|
return;
|
||||||
|
switch (this->_ID) {
|
||||||
|
case 0:
|
||||||
|
controller->layout = ControllableComponent::GAMEPAD_0;
|
||||||
|
break;
|
||||||
|
case 1:
|
||||||
|
controller->layout = ControllableComponent::GAMEPAD_1;
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
controller->layout = ControllableComponent::GAMEPAD_2;
|
||||||
|
break;
|
||||||
|
case 3:
|
||||||
|
controller->layout = ControllableComponent::GAMEPAD_3;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace BMM
|
} // namespace BMM
|
||||||
|
|||||||
@@ -44,6 +44,8 @@ namespace BBM
|
|||||||
//! @inherit
|
//! @inherit
|
||||||
WAL::Component *clone(WAL::Entity &entity) const override;
|
WAL::Component *clone(WAL::Entity &entity) const override;
|
||||||
|
|
||||||
|
void onStart() override;
|
||||||
|
|
||||||
//! @brief Create a new gampad component using default keys.
|
//! @brief Create a new gampad component using default keys.
|
||||||
explicit GamepadComponent(WAL::Entity &entity);
|
explicit GamepadComponent(WAL::Entity &entity);
|
||||||
|
|
||||||
|
|||||||
@@ -3,25 +3,44 @@
|
|||||||
// Edited by Benjamin Henry on 2021-05-20.
|
// Edited by Benjamin Henry on 2021-05-20.
|
||||||
//
|
//
|
||||||
|
|
||||||
|
#include <Component/Controllable/ControllableComponent.hpp>
|
||||||
#include "KeyboardComponent.hpp"
|
#include "KeyboardComponent.hpp"
|
||||||
|
|
||||||
namespace BBM
|
namespace BBM
|
||||||
{
|
{
|
||||||
KeyboardComponent::KeyboardComponent(WAL::Entity &entity,
|
KeyboardComponent::KeyboardComponent(WAL::Entity &entity, ControllableComponent::Layout layout)
|
||||||
Key up,
|
: WAL::Component(entity), layout(layout)
|
||||||
Key down,
|
{
|
||||||
Key left,
|
if (layout == ControllableComponent::KEYBOARD_0) {
|
||||||
Key right,
|
this->keyUp = KEY_W;
|
||||||
Key jump,
|
this->keyDown = KEY_S;
|
||||||
Key bomb,
|
this->keyLeft = KEY_A;
|
||||||
Key pause)
|
this->keyRight = KEY_D;
|
||||||
: WAL::Component(entity), keyJump(jump), keyBomb(bomb), keyPause(pause),
|
this->keyJump = KEY_SPACE;
|
||||||
keyRight(right), keyLeft(left), keyUp(up), keyDown(down)
|
this->keyBomb = KEY_E;
|
||||||
{}
|
this->keyPause = KEY_ESCAPE;
|
||||||
|
} else {
|
||||||
|
this->keyUp = KEY_UP;
|
||||||
|
this->keyDown = KEY_DOWN;
|
||||||
|
this->keyLeft = KEY_LEFT;
|
||||||
|
this->keyRight = KEY_RIGHT;
|
||||||
|
this->keyJump = KEY_RIGHT_CONTROL;
|
||||||
|
this->keyBomb = KEY_ENTER;
|
||||||
|
this->keyPause = KEY_BACKSPACE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
WAL::Component *KeyboardComponent::clone(WAL::Entity &entity) const
|
WAL::Component *KeyboardComponent::clone(WAL::Entity &entity) const
|
||||||
{
|
{
|
||||||
return new KeyboardComponent(entity);
|
return new KeyboardComponent(entity, this->layout);
|
||||||
|
}
|
||||||
|
|
||||||
|
void KeyboardComponent::onStart()
|
||||||
|
{
|
||||||
|
auto *controller = this->_entity.tryGetComponent<ControllableComponent>();
|
||||||
|
if (!controller)
|
||||||
|
return;
|
||||||
|
controller->layout = this->layout;
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace BMM
|
} // namespace BMM
|
||||||
|
|||||||
@@ -7,6 +7,7 @@
|
|||||||
|
|
||||||
#include <Controllers/Keyboard.hpp>
|
#include <Controllers/Keyboard.hpp>
|
||||||
#include "Component/Component.hpp"
|
#include "Component/Component.hpp"
|
||||||
|
#include "Component/Controllable/ControllableComponent.hpp"
|
||||||
#include "Entity/Entity.hpp"
|
#include "Entity/Entity.hpp"
|
||||||
|
|
||||||
using Key = RAY::Controller::Keyboard::Key;
|
using Key = RAY::Controller::Keyboard::Key;
|
||||||
@@ -30,19 +31,16 @@ namespace BBM
|
|||||||
Key keyUp = KEY_W;
|
Key keyUp = KEY_W;
|
||||||
//! @brief move down key
|
//! @brief move down key
|
||||||
Key keyDown = KEY_S;
|
Key keyDown = KEY_S;
|
||||||
|
//! @brief Layout
|
||||||
|
ControllableComponent::Layout layout;
|
||||||
|
|
||||||
//! @inherit
|
//! @inherit
|
||||||
WAL::Component *clone(WAL::Entity &entity) const override;
|
WAL::Component *clone(WAL::Entity &entity) const override;
|
||||||
|
|
||||||
|
void onStart() override;
|
||||||
|
|
||||||
//! @brief Create a new keyboard component using custom keys.
|
//! @brief Create a new keyboard component using custom keys.
|
||||||
explicit KeyboardComponent(WAL::Entity &entity,
|
explicit KeyboardComponent(WAL::Entity &entity, ControllableComponent::Layout layout = ControllableComponent::Layout::KEYBOARD_0);
|
||||||
Key up = KEY_W,
|
|
||||||
Key down = KEY_S,
|
|
||||||
Key left = KEY_A,
|
|
||||||
Key right = KEY_D,
|
|
||||||
Key jump = KEY_SPACE,
|
|
||||||
Key bomb = KEY_E,
|
|
||||||
Key pause = KEY_ESCAPE);
|
|
||||||
|
|
||||||
//! @brief A Keyboard component is copy constructable.
|
//! @brief A Keyboard component is copy constructable.
|
||||||
KeyboardComponent(const KeyboardComponent &) = default;
|
KeyboardComponent(const KeyboardComponent &) = default;
|
||||||
|
|||||||
@@ -255,6 +255,27 @@ namespace BBM
|
|||||||
scene->addEntity("lobby text")
|
scene->addEntity("lobby text")
|
||||||
.addComponent<PositionComponent>(1920 / 2.75, 100, 0)
|
.addComponent<PositionComponent>(1920 / 2.75, 100, 0)
|
||||||
.addComponent<Drawable2DComponent, RAY2D::Text>("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>("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());
|
||||||
|
|
||||||
|
texture->use("assets/buttons/button_new_game.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_new_game_hovered.png");
|
||||||
|
})
|
||||||
|
.addComponent<OnClickComponent>([](WAL::Entity &entity, WAL::Wal &)
|
||||||
|
{
|
||||||
|
gameState._loadedScenes[GameState::SceneID::GameScene] = loadGameScene();
|
||||||
|
gameState.nextScene = BBM::GameState::SceneID::GameScene;
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
auto &back = scene->addEntity("back to menu")
|
auto &back = scene->addEntity("back to menu")
|
||||||
.addComponent<PositionComponent>(10, 1080 - 85, 0)
|
.addComponent<PositionComponent>(10, 1080 - 85, 0)
|
||||||
@@ -275,72 +296,97 @@ namespace BBM
|
|||||||
|
|
||||||
texture->use("assets/buttons/button_back_hovered.png");
|
texture->use("assets/buttons/button_back_hovered.png");
|
||||||
});
|
});
|
||||||
auto &play = scene->addEntity("play button")
|
auto &lavaOption = scene->addEntity("lava option text")
|
||||||
.addComponent<PositionComponent>(1920 / 2.5, 1080 - 180, 0)
|
.addComponent<PositionComponent>(1920 / 6, 2 * 1080 / 3, 0)
|
||||||
.addComponent<Drawable2DComponent, RAY::Texture>("assets/buttons/button_new_game.png")
|
.addComponent<Drawable2DComponent, RAY2D::Text>("Lava: 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());
|
||||||
|
|
||||||
|
if (text->getString().find("Off") != std::string::npos) {
|
||||||
|
text->setText("Lava: On");
|
||||||
|
//do
|
||||||
|
} else {
|
||||||
|
text->setText("Lava: Off");
|
||||||
|
//do
|
||||||
|
}
|
||||||
|
})
|
||||||
.addComponent<OnIdleComponent>([](WAL::Entity &entity, WAL::Wal &)
|
.addComponent<OnIdleComponent>([](WAL::Entity &entity, WAL::Wal &)
|
||||||
{
|
{
|
||||||
RAY::Texture *texture = dynamic_cast<RAY::Texture *>(entity.getComponent<Drawable2DComponent>().drawable.get());
|
entity.getComponent<Drawable2DComponent>().drawable->setColor(BLACK);
|
||||||
|
|
||||||
texture->use("assets/buttons/button_new_game.png");
|
|
||||||
})
|
})
|
||||||
.addComponent<OnHoverComponent>([](WAL::Entity &entity, WAL::Wal &)
|
.addComponent<OnHoverComponent>([](WAL::Entity &entity, WAL::Wal &)
|
||||||
{
|
{
|
||||||
RAY::Texture *texture = dynamic_cast<RAY::Texture *>(entity.getComponent<Drawable2DComponent>().drawable.get());
|
entity.getComponent<Drawable2DComponent>().drawable->setColor(ORANGE);
|
||||||
|
});
|
||||||
|
|
||||||
texture->use("assets/buttons/button_new_game_hovered.png");
|
auto &heightOption = scene->addEntity("Height option text")
|
||||||
})
|
.addComponent<PositionComponent>(1920 / 1.75, 2 * 1080 / 3, 0)
|
||||||
.addComponent<OnClickComponent>([](WAL::Entity &entity, WAL::Wal &)
|
.addComponent<Drawable2DComponent, RAY2D::Text>("2nd Level: Off", 70, RAY::Vector2(), BLACK)
|
||||||
|
.addComponent<OnClickComponent>([](WAL::Entity &entity, WAL::Wal &wal)
|
||||||
{
|
{
|
||||||
gameState.nextScene = BBM::GameState::SceneID::GameScene;
|
RAY2D::Text *text = dynamic_cast<RAY2D::Text *>(entity.getComponent<Drawable2DComponent>().drawable.get());
|
||||||
|
|
||||||
|
if (text->getString().find("Off") != std::string::npos) {
|
||||||
|
text->setText("2nd Level: On");
|
||||||
|
//do
|
||||||
|
} else {
|
||||||
|
text->setText("2nd Level: Off");
|
||||||
|
//do
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.addComponent<OnIdleComponent>([](WAL::Entity &entity, WAL::Wal &)
|
||||||
|
{
|
||||||
|
entity.getComponent<Drawable2DComponent>().drawable->setColor(BLACK);
|
||||||
|
})
|
||||||
|
.addComponent<OnHoverComponent>([](WAL::Entity &entity, WAL::Wal &)
|
||||||
|
{
|
||||||
|
entity.getComponent<Drawable2DComponent>().drawable->setColor(ORANGE);
|
||||||
});
|
});
|
||||||
|
|
||||||
auto &p1tile = scene->addEntity("player1 tile")
|
// auto &p1tile = scene->addEntity("player1 tile")
|
||||||
.addComponent<PositionComponent>(224, 1080 / 3, 0)
|
// .addComponent<PositionComponent>(224, 1080 / 3, 0)
|
||||||
.addComponent<Drawable2DComponent, RAY2D::Rectangle>(RAY::Vector2(), RAY::Vector2(200, 200), WHITE);
|
// .addComponent<Drawable2DComponent, RAY2D::Rectangle>(RAY::Vector2(), RAY::Vector2(200, 200), WHITE);
|
||||||
auto &p1 = scene->addEntity("player1")
|
auto &p1 = scene->addEntity("player1")
|
||||||
.addComponent<PositionComponent>(224, 1080 / 3, 0)
|
.addComponent<PositionComponent>(224, 1080 / 3, 0)
|
||||||
.addComponent<Drawable2DComponent, RAY::Texture>("assets/player/none_icon.png")
|
.addComponent<Drawable2DComponent, RAY::Texture>("assets/player/icons/none.png")
|
||||||
.addComponent<LobbyComponent>(0);
|
.addComponent<LobbyComponent>(0);
|
||||||
auto &p2tile = scene->addEntity("player2 tile")
|
// auto &p2tile = scene->addEntity("player2 tile")
|
||||||
.addComponent<PositionComponent>(2 * 224 + 200, 1080 / 3, 0)
|
// .addComponent<PositionComponent>(2 * 224 + 200, 1080 / 3, 0)
|
||||||
.addComponent<Drawable2DComponent, RAY2D::Rectangle>(RAY::Vector2(), RAY::Vector2(200, 200), WHITE);
|
// .addComponent<Drawable2DComponent, RAY2D::Rectangle>(RAY::Vector2(), RAY::Vector2(200, 200), WHITE);
|
||||||
auto &p2 = scene->addEntity("player2")
|
auto &p2 = scene->addEntity("player2")
|
||||||
.addComponent<PositionComponent>(2 * 224 + 200, 1080 / 3, 0)
|
.addComponent<PositionComponent>(2 * 224 + 200, 1080 / 3, 0)
|
||||||
.addComponent<Drawable2DComponent, RAY::Texture>("assets/player/none_icon.png")
|
.addComponent<Drawable2DComponent, RAY::Texture>("assets/player/icons/none.png")
|
||||||
.addComponent<LobbyComponent>(1);
|
.addComponent<LobbyComponent>(1);
|
||||||
auto &p3tile = scene->addEntity("player3 tile")
|
// auto &p3tile = scene->addEntity("player3 tile")
|
||||||
.addComponent<PositionComponent>(3 * 224 + 2 * 200, 1080 / 3, 0)
|
// .addComponent<PositionComponent>(3 * 224 + 2 * 200, 1080 / 3, 0)
|
||||||
.addComponent<Drawable2DComponent, RAY2D::Rectangle>(RAY::Vector2(), RAY::Vector2(200, 200), WHITE);
|
// .addComponent<Drawable2DComponent, RAY2D::Rectangle>(RAY::Vector2(), RAY::Vector2(200, 200), WHITE);
|
||||||
auto &p3 = scene->addEntity("player3")
|
auto &p3 = scene->addEntity("player3")
|
||||||
.addComponent<PositionComponent>(3 * 224 + 2 * 200, 1080 / 3, 0)
|
.addComponent<PositionComponent>(3 * 224 + 2 * 200, 1080 / 3, 0)
|
||||||
.addComponent<Drawable2DComponent, RAY::Texture>("assets/player/none_icon.png")
|
.addComponent<Drawable2DComponent, RAY::Texture>("assets/player/icons/none.png")
|
||||||
.addComponent<LobbyComponent>(2);
|
.addComponent<LobbyComponent>(2);
|
||||||
auto &p4tile = scene->addEntity("player4 tile")
|
// auto &p4tile = scene->addEntity("player4 tile")
|
||||||
.addComponent<PositionComponent>(4 * 224 + 3 * 200, 1080 / 3, 0)
|
// .addComponent<PositionComponent>(4 * 224 + 3 * 200, 1080 / 3, 0)
|
||||||
.addComponent<Drawable2DComponent, RAY2D::Rectangle>(RAY::Vector2(), RAY::Vector2(200, 200), WHITE);
|
// .addComponent<Drawable2DComponent, RAY2D::Rectangle>(RAY::Vector2(), RAY::Vector2(200, 200), WHITE);
|
||||||
auto &p4 = scene->addEntity("player4")
|
auto &p4 = scene->addEntity("player4")
|
||||||
.addComponent<PositionComponent>(4 * 224 + 3 * 200, 1080 / 3, 0)
|
.addComponent<PositionComponent>(4 * 224 + 3 * 200, 1080 / 3, 0)
|
||||||
.addComponent<Drawable2DComponent, RAY::Texture>("assets/player/none_icon.png")
|
.addComponent<Drawable2DComponent, RAY::Texture>("assets/player/icons/none.png")
|
||||||
.addComponent<LobbyComponent>(3);
|
.addComponent<LobbyComponent>(3);
|
||||||
scene->addEntity("camera")
|
scene->addEntity("camera")
|
||||||
.addComponent<PositionComponent>(8, 20, 7)
|
.addComponent<PositionComponent>(8, 20, 7)
|
||||||
.addComponent<CameraComponent>(Vector3f(8, 0, 8));
|
.addComponent<CameraComponent>(Vector3f(8, 0, 8));
|
||||||
//when a player is ready:
|
|
||||||
p1tile.getComponent<Drawable2DComponent>().drawable.get()->setColor(BLUE);
|
|
||||||
//p2tile.getComponent<Drawable2DComponent>().drawable.get()->setColor(RED);
|
|
||||||
//p3tile.getComponent<Drawable2DComponent>().drawable.get()->setColor(GREEN);
|
|
||||||
//p4tile.getComponent<Drawable2DComponent>().drawable.get()->setColor(YELLOW);
|
|
||||||
|
|
||||||
//pX
|
//pX
|
||||||
p1.getComponent<Drawable2DComponent>().drawable = std::make_shared<RAY::Texture>("assets/player/valid_selection_icon.png");
|
//p1.getComponent<Drawable2DComponent>().drawable = std::make_shared<RAY::Texture>("assets/player/icvalid_selection_icon.png");
|
||||||
|
|
||||||
//to do
|
//to do
|
||||||
// quand no player is reaydy, the play button should be diasbled
|
// quand no player is reaydy, the play button should be diasbled
|
||||||
|
|
||||||
//The other non-ready players shoudl be IAs
|
//The other non-ready players shoudl be IAs
|
||||||
play.getComponent<OnClickComponent>().setButtonLinks(nullptr, nullptr, &back, nullptr);
|
play.getComponent<OnClickComponent>().setButtonLinks(&lavaOption, &back, &back, nullptr);
|
||||||
back.getComponent<OnClickComponent>().setButtonLinks(nullptr, nullptr, nullptr, &play);
|
back.getComponent<OnClickComponent>().setButtonLinks(&play, nullptr, nullptr, &play);
|
||||||
|
lavaOption.getComponent<OnClickComponent>().setButtonLinks(nullptr, &play, nullptr, &heightOption);
|
||||||
|
heightOption.getComponent<OnClickComponent>().setButtonLinks(nullptr, &play, &lavaOption, nullptr);
|
||||||
return scene;
|
return scene;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -416,7 +462,7 @@ namespace BBM
|
|||||||
})
|
})
|
||||||
.addComponent<OnClickComponent>([](WAL::Entity &entity, WAL::Wal &wal)
|
.addComponent<OnClickComponent>([](WAL::Entity &entity, WAL::Wal &wal)
|
||||||
{
|
{
|
||||||
//empty scene
|
gameState._loadedScenes[GameState::SceneID::GameScene].reset();
|
||||||
gameState.nextScene = BBM::GameState::SceneID::MainMenuScene;
|
gameState.nextScene = BBM::GameState::SceneID::MainMenuScene;
|
||||||
});
|
});
|
||||||
play.getComponent<OnClickComponent>().setButtonLinks(nullptr, nullptr, nullptr, &settings);
|
play.getComponent<OnClickComponent>().setButtonLinks(nullptr, nullptr, nullptr, &settings);
|
||||||
@@ -583,6 +629,7 @@ namespace BBM
|
|||||||
{
|
{
|
||||||
entity.getComponent<Drawable2DComponent>().drawable->setColor(ORANGE);
|
entity.getComponent<Drawable2DComponent>().drawable->setColor(ORANGE);
|
||||||
});
|
});
|
||||||
|
|
||||||
auto &back = scene->addEntity("back to menu")
|
auto &back = scene->addEntity("back to menu")
|
||||||
.addComponent<PositionComponent>(10, 1080 - 85, 0)
|
.addComponent<PositionComponent>(10, 1080 - 85, 0)
|
||||||
.addComponent<Drawable2DComponent, RAY::Texture>("assets/buttons/button_back.png")
|
.addComponent<Drawable2DComponent, RAY::Texture>("assets/buttons/button_back.png")
|
||||||
@@ -628,7 +675,7 @@ namespace BBM
|
|||||||
};
|
};
|
||||||
scene->addEntity("player")
|
scene->addEntity("player")
|
||||||
.addComponent<PositionComponent>()
|
.addComponent<PositionComponent>()
|
||||||
.addComponent<Drawable3DComponent, RAY3D::Model>("assets/player/player.iqm", true, std::make_pair(MAP_DIFFUSE, "assets/player/blue.png"))
|
.addComponent<Drawable3DComponent, RAY3D::Model>("assets/player/player.iqm", true, std::make_pair(MAP_DIFFUSE, "assets/player/textures/blue.png"))
|
||||||
.addComponent<ControllableComponent>()
|
.addComponent<ControllableComponent>()
|
||||||
.addComponent<AnimatorComponent>()
|
.addComponent<AnimatorComponent>()
|
||||||
.addComponent<KeyboardComponent>()
|
.addComponent<KeyboardComponent>()
|
||||||
@@ -712,7 +759,7 @@ namespace BBM
|
|||||||
.addComponent<KeyboardComponent>();
|
.addComponent<KeyboardComponent>();
|
||||||
scene.addEntity("Keyboard second control")
|
scene.addEntity("Keyboard second control")
|
||||||
.addComponent<ControllableComponent>()
|
.addComponent<ControllableComponent>()
|
||||||
.addComponent<KeyboardComponent>(KEY_UP, KEY_DOWN, KEY_LEFT, KEY_RIGHT, KEY_RIGHT_CONTROL, KEY_ENTER, KEY_BACKSPACE);
|
.addComponent<KeyboardComponent>(ControllableComponent::Layout::KEYBOARD_1);
|
||||||
for (int i = 0; i < 4; i++) {
|
for (int i = 0; i < 4; i++) {
|
||||||
scene.addEntity("Gamepad controller")
|
scene.addEntity("Gamepad controller")
|
||||||
.addComponent<ControllableComponent>()
|
.addComponent<ControllableComponent>()
|
||||||
@@ -723,7 +770,6 @@ namespace BBM
|
|||||||
void Runner::loadScenes()
|
void Runner::loadScenes()
|
||||||
{
|
{
|
||||||
gameState._loadedScenes[GameState::SceneID::MainMenuScene] = loadMainMenuScene();
|
gameState._loadedScenes[GameState::SceneID::MainMenuScene] = loadMainMenuScene();
|
||||||
gameState._loadedScenes[GameState::SceneID::GameScene] = loadGameScene();
|
|
||||||
gameState._loadedScenes[GameState::SceneID::SettingsScene] = loadSettingsMenuScene();
|
gameState._loadedScenes[GameState::SceneID::SettingsScene] = loadSettingsMenuScene();
|
||||||
gameState._loadedScenes[GameState::SceneID::PauseMenuScene] = loadPauseMenuScene();
|
gameState._loadedScenes[GameState::SceneID::PauseMenuScene] = loadPauseMenuScene();
|
||||||
gameState._loadedScenes[GameState::SceneID::TitleScreenScene] = loadTitleScreenScene();
|
gameState._loadedScenes[GameState::SceneID::TitleScreenScene] = loadTitleScreenScene();
|
||||||
|
|||||||
@@ -1,7 +1,13 @@
|
|||||||
|
//
|
||||||
|
// Created by Zoe Roux on 6/11/21.
|
||||||
|
//
|
||||||
|
|
||||||
#include <Component/Animation/AnimationsComponent.hpp>
|
#include <Component/Animation/AnimationsComponent.hpp>
|
||||||
#include <System/Event/EventSystem.hpp>
|
#include <System/Event/EventSystem.hpp>
|
||||||
|
#include <Component/Renderer/Drawable2DComponent.hpp>
|
||||||
#include "System/Lobby/LobbySystem.hpp"
|
#include "System/Lobby/LobbySystem.hpp"
|
||||||
#include "Component/Controllable/ControllableComponent.hpp"
|
#include "Component/Controllable/ControllableComponent.hpp"
|
||||||
|
#include <algorithm>
|
||||||
|
|
||||||
namespace BBM
|
namespace BBM
|
||||||
{
|
{
|
||||||
@@ -9,13 +15,18 @@ namespace BBM
|
|||||||
: System(wal)
|
: System(wal)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
void LobbySystem::onUpdate(WAL::ViewEntity<LobbyComponent> &entity, std::chrono::nanoseconds dtime)
|
void LobbySystem::onUpdate(WAL::ViewEntity<LobbyComponent, Drawable2DComponent> &entity, std::chrono::nanoseconds dtime)
|
||||||
{
|
{
|
||||||
auto &lobby = entity.get<LobbyComponent>();
|
auto &lobby = entity.get<LobbyComponent>();
|
||||||
if (lobby.layout == ControllableComponent::NONE) {
|
if (lobby.layout == ControllableComponent::NONE) {
|
||||||
for (auto &[_, controller] : this->_wal.getScene()->view<ControllableComponent>()) {
|
for (auto &[_, controller] : this->_wal.getScene()->view<ControllableComponent>()) {
|
||||||
if (controller.jump) {
|
if (controller.jump) {
|
||||||
|
if (std::any_of(this->getView().begin(), this->getView().end(), [&controller](WAL::ViewEntity<LobbyComponent, Drawable2DComponent> &view) {
|
||||||
|
return view.get<LobbyComponent>().layout == controller.layout;
|
||||||
|
}))
|
||||||
|
return;
|
||||||
lobby.layout = controller.layout;
|
lobby.layout = controller.layout;
|
||||||
|
entity.get<Drawable2DComponent>().drawable = std::make_shared<RAY::Texture>("assets/player/icons/blue.png");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -28,4 +39,10 @@ namespace BBM
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//void LobbySystem::updateEntityConnectedUser(WAL::Entity &entity)
|
||||||
|
//{
|
||||||
|
// RAY::Texture *texture = dynamic_cast<RAY::Texture *>(entity.getComponent<Drawable2DComponent>().drawable.get());
|
||||||
|
// texture->use("assets/player/icons/blue.png");
|
||||||
|
//}
|
||||||
}
|
}
|
||||||
@@ -1,3 +1,7 @@
|
|||||||
|
//
|
||||||
|
// Created by Zoe Roux on 6/11/21.
|
||||||
|
//
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "System/System.hpp"
|
#include "System/System.hpp"
|
||||||
@@ -6,11 +10,11 @@
|
|||||||
namespace BBM
|
namespace BBM
|
||||||
{
|
{
|
||||||
//! @brief A system to handle Health entities.
|
//! @brief A system to handle Health entities.
|
||||||
class LobbySystem : public WAL::System<LobbyComponent>
|
class LobbySystem : public WAL::System<LobbyComponent, Drawable2DComponent>
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
//! @inherit
|
//! @inherit
|
||||||
void onUpdate(WAL::ViewEntity<LobbyComponent> &entity, std::chrono::nanoseconds dtime) override;
|
void onUpdate(WAL::ViewEntity<LobbyComponent, Drawable2DComponent> &entity, std::chrono::nanoseconds dtime) override;
|
||||||
|
|
||||||
//! @brief A default constructor
|
//! @brief A default constructor
|
||||||
explicit LobbySystem(WAL::Wal &wal);
|
explicit LobbySystem(WAL::Wal &wal);
|
||||||
|
|||||||