Merge branch 'develop' of github.com:AnonymusRaccoon/Bomberman into parser

# Conflicts:
#	sources/Map/Map.cpp
#	sources/Runner/GameScene.cpp
#	sources/Runner/PauseMenuScene.cpp
#	sources/Runner/Runner.cpp
#	sources/System/Controllable/ControllableSystem.cpp
#	sources/System/Lobby/LobbySystem.cpp
This commit is contained in:
Clément Le Bihan
2021-06-19 14:39:43 +02:00
34 changed files with 219 additions and 165 deletions
+1
View File
@@ -1,5 +1,6 @@
.idea
cmake-build-debug
cmake-build-release
./bomberman
.vscode
build/*
Binary file not shown.

After

Width:  |  Height:  |  Size: 2.1 MiB

+2 -1
View File
@@ -11,7 +11,8 @@ namespace RAY::Drawables::Drawables3D
{
Plane::Plane(const Vector3 &position, const Vector2 &dimensions, const Color &color) :
ADrawable3D(position, color), _dimensions(dimensions)
ADrawable3D(position, color),
_dimensions(dimensions)
{
}
@@ -34,14 +34,16 @@ namespace BBM
//! @brief The X and Z abscis of the movement.
Vector2f move;
//! @brief input value to select
bool select = false;
//! @brief input value for bomb
//! @brief input value for secondary inputs.
bool secondary = false;
//! @brief input value for bomb and selection
bool bomb = false;
//! @brief input value for pause
bool pause = false;
//! @brief The layout used for this controllable.
Layout layout = NONE;
//! @brief True if buttons should be triggered every frame where the key is down, false if the button should only be triggered once the key is released.
bool fastClick = false;
//! @inherit
WAL::Component *clone(WAL::Entity &entity) const override;
@@ -22,9 +22,9 @@ namespace BBM
int _ID;
public:
//! @brief jump key
Button keyJump = GAMEPAD_BUTTON_RIGHT_FACE_DOWN;
Button keySecondary = GAMEPAD_BUTTON_RIGHT_FACE_RIGHT;
//! @brief bomb key
Button keyBomb = GAMEPAD_BUTTON_RIGHT_FACE_RIGHT;
Button keyBomb = GAMEPAD_BUTTON_RIGHT_FACE_DOWN;
//! @brief pause key
Button keyPause = GAMEPAD_BUTTON_MIDDLE;
//! @brief move right key
@@ -16,16 +16,16 @@ namespace BBM
this->keyDown = KEY_S;
this->keyLeft = KEY_A;
this->keyRight = KEY_D;
this->keyJump = KEY_SPACE;
this->keyBomb = KEY_E;
this->keyBomb = KEY_SPACE;
this->keySecondary = KEY_LEFT_CONTROL;
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->keyBomb = KEY_RIGHT_CONTROL;
this->keySecondary = KEY_RIGHT_SHIFT;
this->keyPause = KEY_BACKSPACE;
}
}
@@ -18,7 +18,7 @@ namespace BBM
{
public:
//! @brief jump key
Key keyJump = KEY_SPACE;
Key keySecondary = KEY_SPACE;
//! @brief bomb key
Key keyBomb = KEY_E;
//! @brief pause key
+1
View File
@@ -54,6 +54,7 @@ namespace BBM
constexpr const char Blowable[] = "Blowable";
// interact with visual features like camera
constexpr const char Player[] = "Player";
constexpr const char Background[] = "Background";
constexpr const char Unbreakable[] = "Unbreakable";
constexpr const char Breakable[] = "Breakable";
constexpr const char Hole[] = "Hole";
@@ -15,6 +15,9 @@ namespace BBM
class TimerComponent : public WAL::Component
{
public:
//! @brief Is the ticking of this component disabled?
bool disabled = false;
//! @brief The callback to call when the timer ring.
WAL::Callback<WAL::Entity &, WAL::Wal &> callback;
//! @brief The ring delay of this timer component.
+3 -3
View File
@@ -69,9 +69,9 @@ namespace BBM {
static std::default_random_engine generator(time(nullptr));
std::map<BonusType, float> chanceValue = {
{NOTHING, 100.0f},
{SPEEDUP, 45.0f},
{BOMBSTOCK, 30.0f},
{EXPLOSIONINC, 15.0f},
{BOMBSTOCK, 46.5f},
{SPEEDUP, 31.5f},
{EXPLOSIONINC, 16.5f},
{NOCLIP, 1.5f},
};
std::uniform_int_distribution<int> distribution(1,1000);
+10 -2
View File
@@ -67,10 +67,18 @@ namespace BBM
CollisionComponent::CollidedAxis collidedAxis)
{
auto *health = entity.tryGetComponent<HealthComponent>();
auto *movable = entity.tryGetComponent<MovableComponent>();
auto *wallPos = wall.tryGetComponent<PositionComponent>();
auto *entityPos = entity.tryGetComponent<PositionComponent>();
if (!health)
return;
health->takeDmg(health->getHealthPoint());
auto posWall = Vector3f(wallPos->position.x, wallPos->position.y + 1, wallPos->position.z);
auto vec = (posWall - entityPos->position).abs();
if (vec.x < 0.3 && vec.z < 0.3 && posWall.distance(entityPos->position) < 0.5) {
health->takeDmg(health->getHealthPoint());
movable->_velocity = Vector3f();
}
}
void MapGenerator::wallCollision(WAL::Entity &entity,
@@ -296,7 +304,7 @@ namespace BBM
.addComponent<TagComponent<Hole>>()
.addComponent<CollisionComponent>(
WAL::Callback<WAL::Entity &, const WAL::Entity &, CollisionComponent::CollidedAxis>(),
&MapGenerator::holeCollide, Vector3f(0.25, 0.25, 0.25),Vector3f(0.75, 1.75, 0.75));
&MapGenerator::holeCollide, 0.25, 0.75);
if (coords.y == 0)
holeEntity.addComponent<Drawable3DComponent, RAY3D::Model>(holeObj, false, std::make_pair(MAP_DIFFUSE, holePng), Vector3f(1,1,1), 180);
else
+4 -1
View File
@@ -32,6 +32,9 @@ namespace BBM
};
//! @brief The scene before the actual one. Used for back buttons.
SceneID previousScene = SplashScreen;
//! @brief The currently loaded scene
SceneID currentScene = SplashScreen;
@@ -39,6 +42,6 @@ namespace BBM
SceneID nextScene = SplashScreen;
//! @brief The list of loaded scenes.
std::unordered_map<SceneID, std::shared_ptr<WAL::Scene>> _loadedScenes = {};
std::unordered_map<SceneID, std::shared_ptr<WAL::Scene>> loadedScenes = {};
};
}
+7
View File
@@ -68,6 +68,13 @@ namespace BBM
return *this;
}
template<typename T2>
Vector2<T> operator-(const Vector2<T2> &vec) const
{
return Vector2<T>(this->x - vec.x, this->y - vec.y);
}
template<typename T2>
Vector2<T> &operator*=(T2 d)
{
+1 -1
View File
@@ -182,7 +182,7 @@ namespace BBM {
auto start = tmpAssets.find_last_of('/') + 1;
auto colorStr = tmpAssets.substr(start, tmpAssets.length() - start - 4);
auto color = map.at(colorStr);
auto resumeScene = Runner::gameState._loadedScenes[GameState::SceneID::ResumeLobbyScene];
auto resumeScene = Runner::gameState.loadedScenes[GameState::SceneID::ResumeLobbyScene];
auto &playerTile = resumeScene->addEntity("player tile")
.addComponent<PositionComponent>(224 * (countPlayer + 1) + 200 * countPlayer, 1080 / 3, 0)
.addComponent<Drawable2DComponent, RAY2D::Rectangle>(RAY::Vector2(224 * (countPlayer + 1) + 200 * countPlayer, 1080 / 3), RAY::Vector2(200, 200), color);
+9 -8
View File
@@ -21,10 +21,8 @@
#include "Component/Renderer/Drawable3DComponent.hpp"
#include "Component/Shaders/Items/AlphaCtxShaderComponent.hpp"
#include "Component/Speed/SpeedComponent.hpp"
#include "Component/Renderer/Drawable2DComponent.hpp"
#include <Drawables/Image.hpp>
#include "Component/Shaders/ShaderComponent.hpp"
#include "Drawables/Texture.hpp"
#include "Component/Gravity/GravityComponent.hpp"
#include "Component/BumperTimer/BumperTimerComponent.hpp"
#include "Component/Timer/TimerComponent.hpp"
@@ -44,8 +42,11 @@ namespace BBM
.addComponent<PositionComponent>(8, 0, -5)
.addComponent<CameraComponent>(Vector3f(8, 0, 8));
scene->addEntity("background image")
.addComponent<Drawable2DComponent, RAY::Texture>(true, "assets/backgrounds/game.png", false)
.addComponent<PositionComponent>();
.addComponent<Drawable3DComponent, RAY3D::Model>("assets/map/breakable_wall.obj", true, std::make_pair(MAP_DIFFUSE, "assets/backgrounds/game.png"), Vector3f(50, 1, 50))
.addComponent<PositionComponent>(5, -2, 0);
scene->addEntity("background image")
.addComponent<Drawable3DComponent, RAY3D::Model>("assets/map/breakable_wall.obj", true, std::make_pair(MAP_DIFFUSE, "assets/backgrounds/gameWall.png"), Vector3f(50, 1, 50), -90, Vector3f(), Vector3f(1, 0, 0))
.addComponent<PositionComponent>(5, 14, 22);
return scene;
}
@@ -60,7 +61,7 @@ namespace BBM
return scene.addEntity("Player")
.addComponent<PositionComponent>()
.addComponent<Drawable3DComponent, RAY3D::Model>("assets/player/player.iqm", true)
.addComponent<Drawable3DComponent, RAY3D::Model>("assets/player/player.iqm", true, std::nullopt, Vector3f(.75, .75, .75))
.addComponent<ScoreComponent>()
.addComponent<AnimatorComponent>()
.addComponent<GravityComponent>()
@@ -70,10 +71,10 @@ namespace BBM
.addComponent<TagComponent<Player>>()
.addComponent<SpeedComponent>()
.addComponent<AnimationsComponent>("assets/player/player.iqm", 3)
.addComponent<CollisionComponent>(BBM::Vector3f{0.25, 0, 0.25}, BBM::Vector3f{.75, 2, .75})
.addComponent<CollisionComponent>(BBM::Vector3f{0.25, 0, 0.25}, BBM::Vector3f{.6, 2, .6})
.addComponent<MovableComponent>()
.addComponent<AlphaVarShaderComponent>()
.addComponent<ShaderComponentModel>("assets/shaders/alpha.fs", "", [](WAL::Entity &myEntity, WAL::Wal &wal, std::chrono::nanoseconds dtime) {
.addComponent<ShaderComponentModel>("assets/shaders/alpha.fs", "", [](WAL::Entity &myEntity, WAL::Wal &, std::chrono::nanoseconds dtime) {
auto &ctx = myEntity.getComponent<AlphaVarShaderComponent>();
ctx.clock += dtime;
@@ -123,7 +124,7 @@ namespace BBM
if (entity.hasComponent<TimerComponent>())
return;
entity.getComponent<ControllableComponent>().disabled = true;
entity.addComponent<TimerComponent>(1s, [](WAL::Entity &ent, WAL::Wal &wal) {
entity.addComponent<TimerComponent>(1s, [](WAL::Entity &ent, WAL::Wal &) {
ent.scheduleDeletion();
});
});
+5 -5
View File
@@ -37,16 +37,16 @@ namespace BBM
.addComponent<Drawable2DComponent, RAY2D::Text>("How To Play?", 120, RAY::Vector2(), ORANGE);
scene->addEntity("select text")
.addComponent<PositionComponent>(1920 / 8, 1080 / 3, 0)
.addComponent<Drawable2DComponent, RAY2D::Text>("Select:", 60, RAY::Vector2(), ORANGE);
.addComponent<Drawable2DComponent, RAY2D::Text>("Select/Drop Bomb:", 60, RAY::Vector2(), ORANGE);
scene->addEntity("select")
.addComponent<PositionComponent>(1920 / 7, 1080 / 2.5, 0)
.addComponent<Drawable2DComponent, RAY2D::Text>("Space/A Button", 35, RAY::Vector2(), BLACK);
.addComponent<Drawable2DComponent, RAY2D::Text>("Space/Left CTRL/A Button", 35, RAY::Vector2(), BLACK);
scene->addEntity("change skin text")
.addComponent<PositionComponent>(1920 / 8, 1080 / 2, 0)
.addComponent<Drawable2DComponent, RAY2D::Text>("Change Skin/Drop Bomb:", 60, RAY::Vector2(), ORANGE);
.addComponent<Drawable2DComponent, RAY2D::Text>("Change Skin:", 60, RAY::Vector2(), ORANGE);
scene->addEntity("change skin")
.addComponent<PositionComponent>(1920 / 7, 1080 / 1.75, 0)
.addComponent<Drawable2DComponent, RAY2D::Text>("E/B Button", 35, RAY::Vector2(), BLACK);
.addComponent<Drawable2DComponent, RAY2D::Text>("Left ctrl/Right shift/B Button", 35, RAY::Vector2(), BLACK);
scene->addEntity("move text")
.addComponent<PositionComponent>(1920 / 1.75, 1080 / 3, 0)
.addComponent<Drawable2DComponent, RAY2D::Text>("Move:", 60, RAY::Vector2(), ORANGE);
@@ -58,7 +58,7 @@ namespace BBM
.addComponent<Drawable2DComponent, RAY2D::Text>("Back/Pause:", 60, RAY::Vector2(), ORANGE);
scene->addEntity("back")
.addComponent<PositionComponent>(1920 / 1.75, 1080 / 1.75, 0)
.addComponent<Drawable2DComponent, RAY2D::Text>("Esc / Controller's Home button:", 35, RAY::Vector2(), BLACK);
.addComponent<Drawable2DComponent, RAY2D::Text>("Esc/Backspace/Controller's Home button:", 35, RAY::Vector2(), BLACK);
scene->addEntity("back to menu")
.addComponent<PositionComponent>(10, 1080 - 85, 0)
.addComponent<Drawable2DComponent, RAY::Texture>("assets/buttons/button_back.png")
+8 -33
View File
@@ -16,7 +16,6 @@
#include <Component/Animator/AnimatorComponent.hpp>
#include <Component/Tag/TagComponent.hpp>
#include <Drawables/Texture.hpp>
#include "System/Sound/PlayerSoundManagerSystem.hpp"
#include "System/Music/MusicSystem.hpp"
#include "System/Lobby/LobbySystem.hpp"
#include "Component/Lobby/LobbyComponent.hpp"
@@ -82,19 +81,20 @@ namespace BBM
auto &back = scene->addEntity("back to menu")
.addComponent<PositionComponent>(10, 1080 - 85, 0)
.addComponent<Drawable2DComponent, RAY::Texture>("assets/buttons/button_back.png")
.addComponent<OnClickComponent>([](WAL::Entity &entity, WAL::Wal &)
.addComponent<OnClickComponent>([](WAL::Entity &, WAL::Wal &wal)
{
wal.getSystem<LobbySystem>().unloadLobby();
gameState.nextScene = BBM::GameState::SceneID::MainMenuScene;
})
.addComponent<OnIdleComponent>([](WAL::Entity &entity, WAL::Wal &)
{
RAY::Texture *texture = dynamic_cast<RAY::Texture *>(entity.getComponent<Drawable2DComponent>().drawable.get());
auto *texture = dynamic_cast<RAY::Texture *>(entity.getComponent<Drawable2DComponent>().drawable.get());
texture->use("assets/buttons/button_back.png");
})
.addComponent<OnHoverComponent>([](WAL::Entity &entity, WAL::Wal &)
{
RAY::Texture *texture = dynamic_cast<RAY::Texture *>(entity.getComponent<Drawable2DComponent>().drawable.get());
auto *texture = dynamic_cast<RAY::Texture *>(entity.getComponent<Drawable2DComponent>().drawable.get());
texture->use("assets/buttons/button_back_hovered.png");
});
@@ -117,32 +117,8 @@ namespace BBM
texture->use("assets/buttons/button_htp_hovered.png");
});
auto &lavaOption = scene->addEntity("lava option text")
.addComponent<PositionComponent>(1920 / 6, 1.85 * 1080 / 3 - 50, 0)
.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 &)
{
entity.getComponent<Drawable2DComponent>().drawable->setColor(BLACK);
})
.addComponent<OnHoverComponent>([](WAL::Entity &entity, WAL::Wal &)
{
entity.getComponent<Drawable2DComponent>().drawable->setColor(ORANGE);
});
auto &heightOption = scene->addEntity("Height option text")
.addComponent<PositionComponent>(1920 / 6, 2.1 * 1080 / 3 - 50, 0)
.addComponent<PositionComponent>(1920 / 6, 2 * 1080 / 3 - 50, 0)
.addComponent<Drawable2DComponent, RAY2D::Text>("2nd Level: Off", 70, RAY::Vector2(), BLACK)
.addComponent<OnClickComponent>([](WAL::Entity &entity, WAL::Wal &wal)
{
@@ -217,12 +193,11 @@ namespace BBM
scene->addEntity("camera")
.addComponent<PositionComponent>(-5, 0, -5)
.addComponent<CameraComponent>(Vector3f(8, 0, 8));
play.getComponent<OnClickComponent>().setButtonLinks(&lavaOption, &back, &back, &howToPlay);
play.getComponent<OnClickComponent>().setButtonLinks(&heightOption, &back, &back, &howToPlay);
howToPlay.getComponent<OnClickComponent>().setButtonLinks(&play, nullptr, &play);
back.getComponent<OnClickComponent>().setButtonLinks(&play, nullptr, nullptr, &play);
lavaOption.getComponent<OnClickComponent>().setButtonLinks(nullptr, &heightOption, nullptr, &aiMore);
heightOption.getComponent<OnClickComponent>().setButtonLinks(&lavaOption, &play, nullptr, &aiLess);
aiMore.getComponent<OnClickComponent>().setButtonLinks(nullptr, &aiLess, &lavaOption, nullptr);
heightOption.getComponent<OnClickComponent>().setButtonLinks(nullptr, &play, nullptr, &aiLess);
aiMore.getComponent<OnClickComponent>().setButtonLinks(nullptr, &aiLess, &heightOption, nullptr);
aiLess.getComponent<OnClickComponent>().setButtonLinks(&aiMore, &play, &heightOption, nullptr);
return scene;
}
+2 -2
View File
@@ -77,7 +77,7 @@ namespace BBM
ParserYAML::load(gameScene);
} catch (std::exception const &err) {
std::cout << err.what() << std::endl;
Runner::gameState._loadedScenes[GameState::SceneID::MainMenuScene]->addEntity("Error message parser")
Runner::gameState.loadedScenes[GameState::SceneID::MainMenuScene]->addEntity("Error message parser")
.addComponent<PositionComponent>(1920 / 5, 2 * 1080 / 4.25, 0)
.addComponent<TimerComponent>(3s, [](WAL::Entity &myEntity, WAL::Wal &) {
myEntity.scheduleDeletion();
@@ -86,7 +86,7 @@ namespace BBM
gameState.nextScene = BBM::GameState::SceneID::MainMenuScene;
return;
}
Runner::gameState._loadedScenes[GameState::SceneID::GameScene] = gameScene;
Runner::gameState.loadedScenes[GameState::SceneID::GameScene] = gameScene;
});
auto &settings = scene->addEntity("settings button")
.addComponent<PositionComponent>(1920 / 2.5, 1080 - 430, 0)
+36 -11
View File
@@ -3,12 +3,15 @@
#include <Wal.hpp>
#include "Runner.hpp"
#include <map>
#include <System/Renderer/CameraSystem.hpp>
#include "Component/Health/HealthComponent.hpp"
#include "Component/Timer/TimerComponent.hpp"
#include "Component/Tag/TagComponent.hpp"
#include <Parser/ParserYaml.hpp>
#include "Component/Music/MusicComponent.hpp"
#include "Component/Sound/SoundComponent.hpp"
#include "Component/Controllable/ControllableComponent.hpp"
#include "Component/Position/PositionComponent.hpp"
#include "Component/Keyboard/KeyboardComponent.hpp"
#include "Component/Renderer/Drawable2DComponent.hpp"
#include "Component/Button/ButtonComponent.hpp"
#include "Drawables/2D/Text.hpp"
@@ -43,18 +46,39 @@ namespace BBM
.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());
auto *texture = dynamic_cast<RAY::Texture *>(entity.getComponent<Drawable2DComponent>().drawable.get());
texture->use("assets/buttons/button_back.png");
})
.addComponent<OnHoverComponent>([](WAL::Entity &entity, WAL::Wal &)
{
RAY::Texture *texture = dynamic_cast<RAY::Texture *>(entity.getComponent<Drawable2DComponent>().drawable.get());
auto *texture = dynamic_cast<RAY::Texture *>(entity.getComponent<Drawable2DComponent>().drawable.get());
texture->use("assets/buttons/button_back_hovered.png");
})
.addComponent<OnClickComponent>([](WAL::Entity &entity, WAL::Wal &)
.addComponent<OnClickComponent>([](WAL::Entity &, WAL::Wal &)
{
auto &gameScene = gameState.loadedScenes[BBM::GameState::SceneID::GameScene];
for (auto &[entity, controller, _] : gameScene->view<ControllableComponent, HealthComponent>()) {
controller.disabled = true;
controller.pause = false;
controller.bomb = false;
}
for (auto &[_, timer] : gameScene->view<TimerComponent>())
timer.disabled = true;
gameScene->scheduleNewEntity("Restart timer")
.addComponent<TimerComponent>(std::chrono::seconds(3), [gameScene](WAL::Entity &entity, WAL::Wal &) {
for (auto &view : gameScene->view<ControllableComponent, HealthComponent>()) {
if (view.get<HealthComponent>().getHealthPoint() > 0)
view.get<ControllableComponent>().disabled = false;
}
for (auto &view : gameScene->view<TimerComponent>())
view.get<TimerComponent>().disabled = false;
entity.scheduleDeletion();
})
.addComponent<PositionComponent>(1920 / 2 - 2 * 30, 1080 / 2, 0)
.addComponent<TagComponent<"Timer">>()
.addComponent<Drawable2DComponent, RAY2D::Text>("", 60, RAY::Vector2(), ORANGE);
gameState.nextScene = BBM::GameState::SceneID::GameScene;
});
auto &save = scene->addEntity("save & quit button")
@@ -76,7 +100,7 @@ namespace BBM
{
if (!std::filesystem::exists("save"))
std::filesystem::create_directories("save");
ParserYAML::save(Runner::gameState._loadedScenes[GameState::SceneID::GameScene]);
ParserYAML::save(Runner::gameState.loadedScenes[GameState::SceneID::GameScene]);
gameState.nextScene = BBM::GameState::SceneID::MainMenuScene;
});
auto &settings = scene->addEntity("settings button")
@@ -84,17 +108,17 @@ namespace BBM
.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());
auto *texture = dynamic_cast<RAY::Texture *>(entity.getComponent<Drawable2DComponent>().drawable.get());
texture->use("assets/buttons/button_settings.png");
})
.addComponent<OnHoverComponent>([](WAL::Entity &entity, WAL::Wal &)
{
RAY::Texture *texture = dynamic_cast<RAY::Texture *>(entity.getComponent<Drawable2DComponent>().drawable.get());
auto *texture = dynamic_cast<RAY::Texture *>(entity.getComponent<Drawable2DComponent>().drawable.get());
texture->use("assets/buttons/button_settings_hovered.png");
})
.addComponent<OnClickComponent>([](WAL::Entity &entity, WAL::Wal &)
.addComponent<OnClickComponent>([](WAL::Entity &, WAL::Wal &)
{
gameState.nextScene = BBM::GameState::SceneID::SettingsScene;
});
@@ -103,18 +127,19 @@ namespace BBM
.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());
auto *texture = dynamic_cast<RAY::Texture *>(entity.getComponent<Drawable2DComponent>().drawable.get());
texture->use("assets/buttons/button_exit.png");
})
.addComponent<OnHoverComponent>([](WAL::Entity &entity, WAL::Wal &)
{
RAY::Texture *texture = dynamic_cast<RAY::Texture *>(entity.getComponent<Drawable2DComponent>().drawable.get());
auto *texture = dynamic_cast<RAY::Texture *>(entity.getComponent<Drawable2DComponent>().drawable.get());
texture->use("assets/buttons/button_exit_hovered.png");
})
.addComponent<OnClickComponent>([](WAL::Entity &entity, WAL::Wal &wal)
.addComponent<OnClickComponent>([](WAL::Entity &, WAL::Wal &wal)
{
wal.getSystem<CameraSystem>().hasEnded = false;
gameState.nextScene = BBM::GameState::SceneID::MainMenuScene;
});
//needed material
+24 -27
View File
@@ -3,7 +3,6 @@
//
#include <Wal.hpp>
#include <iostream>
#include "System/Movable/MovableSystem.hpp"
#include "System/Renderer/RenderSystem.hpp"
#include <Drawables/2D/Rectangle.hpp>
@@ -12,15 +11,9 @@
#include "System/Controllable/ControllableSystem.hpp"
#include "System/Gamepad/GamepadSystem.hpp"
#include <System/Collision/CollisionSystem.hpp>
#include "Component/Button/ButtonComponent.hpp"
#include <Component/Collision/CollisionComponent.hpp>
#include <Component/Controllable/ControllableComponent.hpp>
#include <Component/IAControllable/IAControllableComponent.hpp>
#include <Component/Keyboard/KeyboardComponent.hpp>
#include <System/Gamepad/GamepadSystem.hpp>
#include "Component/Renderer/CameraComponent.hpp"
#include "Component/Renderer/Drawable3DComponent.hpp"
#include "Component/Renderer/Drawable2DComponent.hpp"
#include "Runner.hpp"
#include "Models/GameState.hpp"
#include <System/Timer/TimerSystem.hpp>
@@ -37,7 +30,6 @@
#include "System/Shaders/ShaderDrawable2DSystem.hpp"
#include "System/Shaders/ShaderModelSystem.hpp"
#include "System/Animation/AnimationsSystem.hpp"
#include "Map/Map.hpp"
#include "System/IAControllable/IAControllableSystem.hpp"
#include "System/MenuControllable/MenuControllableSystem.hpp"
#include <System/Bomb/BombSystem.hpp>
@@ -52,7 +44,6 @@
#include "System/Lobby/LobbySystem.hpp"
#include "System/Score/ScoreSystem.hpp"
#include "System/EndCondition/EndConditionSystem.hpp"
#include "Component/Lobby/LobbyComponent.hpp"
#include "System/Bonus/BonusUISystem.hpp"
namespace BBM
@@ -68,21 +59,27 @@ namespace BBM
engine.shouldClose = true;
if (gameState.currentScene == GameState::SceneID::GameScene) {
for (auto &[_, component]: engine.getScene()->view<ControllableComponent>()) {
component.fastClick = true;
if (component.pause && gameState.currentScene == GameState::SceneID::GameScene) {
gameState.nextScene = GameState::SceneID::PauseMenuScene;
break;
}
}
if (gameState.nextScene != GameState::SceneID::GameScene)
engine.getSystem<CameraSystem>().hasEnded = false;
}
if (gameState.nextScene == gameState.currentScene)
return;
if (gameState.nextScene == GameState::SceneID::ScoreScene)
gameState._loadedScenes[GameState::SceneID::ScoreScene] = Runner::loadScoreScene(*engine.getScene());
if (gameState.previousScene == GameState::SceneID::GameScene) {
for (auto &[_, component]: engine.getScene()->view<ControllableComponent>()) {
component.fastClick = false;
}
}
if (gameState.nextScene == GameState::SceneID::ScoreScene) {
gameState.loadedScenes[GameState::SceneID::ScoreScene] = Runner::loadScoreScene(*engine.getScene());
}
RAY::Window::getInstance().setVisibleCursor(gameState.nextScene != GameState::SceneID::GameScene);
gameState._loadedScenes[gameState.currentScene] = engine.getScene();
engine.changeScene(gameState._loadedScenes[gameState.nextScene]);
gameState.loadedScenes[gameState.currentScene] = engine.getScene();
engine.changeScene(gameState.loadedScenes[gameState.nextScene]);
gameState.previousScene = gameState.currentScene;
gameState.currentScene = gameState.nextScene;
}
@@ -113,10 +110,10 @@ namespace BBM
.addSystem<ShaderSystem>()
.addSystem<ShaderModelSystem>()
.addSystem<ShaderDrawable2DSystem>()
.addSystem<EndConditionSystem>()
.addSystem<ScoreSystem>()
.addSystem<CameraSystem>()
.addSystem<ResumeLobbySystem>()
.addSystem<EndConditionSystem>()
.addSystem<MusicSystem>();
}
@@ -153,15 +150,15 @@ namespace BBM
void Runner::loadScenes()
{
gameState._loadedScenes[GameState::SceneID::MainMenuScene] = loadMainMenuScene();
gameState._loadedScenes[GameState::SceneID::SettingsScene] = loadSettingsMenuScene();
gameState._loadedScenes[GameState::SceneID::PauseMenuScene] = loadPauseMenuScene();
gameState._loadedScenes[GameState::SceneID::TitleScreenScene] = loadTitleScreenScene();
gameState._loadedScenes[GameState::SceneID::CreditScene] = loadCreditScene();
gameState._loadedScenes[GameState::SceneID::SplashScreen] = loadSplashScreenScene();
gameState._loadedScenes[GameState::SceneID::LobbyScene] = loadLobbyScene();
gameState._loadedScenes[GameState::SceneID::ResumeLobbyScene] = loadResumeLobbyScene();
gameState._loadedScenes[GameState::SceneID::HowToPlayScene] = loadHowToPlayScene();
gameState.loadedScenes[GameState::SceneID::MainMenuScene] = loadMainMenuScene();
gameState.loadedScenes[GameState::SceneID::SettingsScene] = loadSettingsMenuScene();
gameState.loadedScenes[GameState::SceneID::PauseMenuScene] = loadPauseMenuScene();
gameState.loadedScenes[GameState::SceneID::TitleScreenScene] = loadTitleScreenScene();
gameState.loadedScenes[GameState::SceneID::CreditScene] = loadCreditScene();
gameState.loadedScenes[GameState::SceneID::SplashScreen] = loadSplashScreenScene();
gameState.loadedScenes[GameState::SceneID::LobbyScene] = loadLobbyScene();
gameState.loadedScenes[GameState::SceneID::ResumeLobbyScene] = loadResumeLobbyScene();
gameState.loadedScenes[GameState::SceneID::HowToPlayScene] = loadHowToPlayScene();
}
int Runner::run()
@@ -171,9 +168,9 @@ namespace BBM
Runner::addSystems(wal);
Runner::enableRaylib(wal);
Runner::loadScenes();
wal.changeScene(Runner::gameState._loadedScenes[GameState::SceneID::SplashScreen]);
wal.changeScene(Runner::gameState.loadedScenes[GameState::SceneID::SplashScreen]);
wal.run<GameState>(Runner::updateState, Runner::gameState);
gameState._loadedScenes.clear();
gameState.loadedScenes.clear();
return 0;
}
}
+15 -12
View File
@@ -35,11 +35,12 @@ namespace BBM
"1st", "2nd", "3rd", "4th"
};
for (WAL::Entity &entity : gameScene.view<ScoreComponent, Drawable3DComponent>())
for (WAL::Entity &entity: gameScene.view<ScoreComponent, Drawable3DComponent>())
players.emplace_back(entity);
std::sort(players.begin(), players.end(), [](WAL::Entity &entityA, WAL::Entity &entityB) {
return entityA.getComponent<ScoreComponent>().aliveTime > entityB.getComponent<ScoreComponent>().aliveTime;
});
auto bestTime = players.front().get().getComponent<ScoreComponent>().aliveTime;
int playerID = 0;
for (auto &entity : players) {
@@ -59,7 +60,7 @@ namespace BBM
}
addMenuControl(*scene, sounds);
scene->addEntity("Audio ressources")
scene->addEntity("Audio resources")
.addComponent<MusicComponent>("assets/musics/music_result.ogg")
.addComponent<SoundComponent>(sounds);
scene->addEntity("background")
@@ -74,19 +75,23 @@ namespace BBM
scene->addEntity("scene title text")
.addComponent<PositionComponent>(1920 / 2.37, 250, 0)
.addComponent<Drawable2DComponent, RAY2D::Text>("CONGRATS", 50, RAY::Vector2(), ORANGE);
for (size_t i = 0; i < players.size(); i++) {
for (std::size_t i = 0; i < players.size(); i++) {
std::size_t place = i;
if (players[i].get().getComponent<ScoreComponent>().aliveTime == bestTime)
place = 0;
scene->addEntity("player tile")
.addComponent<PositionComponent>(224 * (i + 1) + 200 * i, 1080 / 2.5, 0)
.addComponent<Drawable2DComponent, RAY2D::Rectangle>(RAY::Vector2(224 * (i + 1) + 200 * i, 1080 / 3),
RAY::Vector2(200, 200), tilesColor[i]);
RAY::Vector2(200, 200), tilesColor[place]);
scene->addEntity("player rank name")
.addComponent<PositionComponent>(224 * (i + 1) + 200 * i, 1080 / 2.75, 0)
.addComponent<Drawable2DComponent, RAY2D::Text>(rankName[i], 30,
.addComponent<Drawable2DComponent, RAY2D::Text>(rankName[place], 30,
RAY::Vector2(224 * (i + 1) + 200 * i, 1080 / 3),
tilesColor[i]);
tilesColor[place]);
scene->addEntity("player")
.addComponent<PositionComponent>(224 * (i + 1) + 200 * i, 1080 / 2.5, 0)
.addComponent<Drawable2DComponent, RAY::Texture>(playersIconPath[i]);
.addComponent<Drawable2DComponent, RAY::Texture>(playersIconPath[place]);
}
auto &play = scene->addEntity("play button")
.addComponent<PositionComponent>(1920 / 2.5, 1080 - 180, 0)
@@ -108,17 +113,15 @@ namespace BBM
auto &back = scene->addEntity("back to main menu")
.addComponent<PositionComponent>(10, 1080 - 85, 0)
.addComponent<Drawable2DComponent, RAY::Texture>("assets/buttons/button_back.png")
.addComponent<OnClickComponent>([](WAL::Entity &entity, WAL::Wal &) {
.addComponent<OnClickComponent>([](WAL::Entity &, WAL::Wal &) {
gameState.nextScene = BBM::GameState::SceneID::MainMenuScene;
})
.addComponent<OnIdleComponent>([](WAL::Entity &entity, WAL::Wal &) {
RAY::Texture *texture = dynamic_cast<RAY::Texture *>(entity.getComponent<Drawable2DComponent>().drawable.get());
auto *texture = dynamic_cast<RAY::Texture *>(entity.getComponent<Drawable2DComponent>().drawable.get());
texture->use("assets/buttons/button_back.png");
})
.addComponent<OnHoverComponent>([](WAL::Entity &entity, WAL::Wal &) {
RAY::Texture *texture = dynamic_cast<RAY::Texture *>(entity.getComponent<Drawable2DComponent>().drawable.get());
auto *texture = dynamic_cast<RAY::Texture *>(entity.getComponent<Drawable2DComponent>().drawable.get());
texture->use("assets/buttons/button_back_hovered.png");
});
back.getComponent<OnClickComponent>().setButtonLinks(&play, nullptr, nullptr, &play);
+12 -12
View File
@@ -97,18 +97,18 @@ namespace BBM
texture->use("assets/buttons/button_minus_hovered.png");
});
auto &musicLevel = scene->addEntity("music level text")
scene->addEntity("music level text")
.addComponent<PositionComponent>(1920 / 2.5, 1080 - 100 - 460, 0)
.addComponent<Drawable2DComponent, RAY2D::Rectangle>(RAY::Vector2(), RAY::Vector2(30, 10), BLACK)
.addComponent<StatComponent>([audio](Drawable2DComponent &drawble) {
const MusicComponent *music = audio.tryGetComponent<MusicComponent>();
const MusicComponent *musicCmp = audio.tryGetComponent<MusicComponent>();
if (!music)
if (!musicCmp)
return;
RAY2D::Rectangle *rect = dynamic_cast<RAY2D::Rectangle *>(drawble.drawable.get());
if (!rect)
return;
rect->setWidth((13 * 36.5) * music->volume);
rect->setWidth((13 * 36.5) * musicCmp->volume);
});
auto &sound = scene->addEntity("sound text")
@@ -172,18 +172,18 @@ namespace BBM
texture->use("assets/buttons/button_minus_hovered.png");
});
auto &soundLevel = scene->addEntity("sound level text")
scene->addEntity("sound level text")
.addComponent<PositionComponent>(1920 / 2.5, 1080 - 100 - 280, 0)
.addComponent<Drawable2DComponent, RAY2D::Rectangle>(RAY::Vector2(), RAY::Vector2(30, 10), BLACK)
.addComponent<StatComponent>([audio](Drawable2DComponent &drawble) {
const SoundComponent *sound = audio.tryGetComponent<SoundComponent>();
.addComponent<StatComponent>([audio](Drawable2DComponent &drawable) {
const auto *soundCmp = audio.tryGetComponent<SoundComponent>();
if (!sound)
if (!soundCmp)
return;
RAY2D::Rectangle *rect = dynamic_cast<RAY2D::Rectangle *>(drawble.drawable.get());
auto *rect = dynamic_cast<RAY2D::Rectangle *>(drawable.drawable.get());
if (!rect)
return;
rect->setWidth((13 * 36.5) * sound->volume);
rect->setWidth((13 * 36.5) * soundCmp->volume);
});
auto &debug = scene->addEntity("debug text")
@@ -191,7 +191,7 @@ namespace BBM
.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());
auto *text = dynamic_cast<RAY2D::Text *>(entity.getComponent<Drawable2DComponent>().drawable.get());
if (text->getString().find("Off") != std::string::npos) {
text->setText("Debug Mode: On");
@@ -239,7 +239,7 @@ namespace BBM
.addComponent<Drawable2DComponent, RAY::Texture>("assets/buttons/button_back.png")
.addComponent<OnClickComponent>([](WAL::Entity &entity, WAL::Wal &)
{
gameState.nextScene = BBM::GameState::SceneID::MainMenuScene;
gameState.nextScene = gameState.previousScene;
})
.addComponent<OnIdleComponent>([](WAL::Entity &entity, WAL::Wal &)
{
+14 -1
View File
@@ -3,6 +3,10 @@
//
#include "PlayerBonusSystem.hpp"
#include "Component/Position/PositionComponent.hpp"
#include "Component/Health//HealthComponent.hpp"
#include "Component/Tag/TagComponent.hpp"
#include "Component/Collision/CollisionComponent.hpp"
using namespace std::chrono_literals;
@@ -17,9 +21,18 @@ namespace BBM
auto &playerBonus = entity.get<PlayerBonusComponent>();
playerBonus.nextNoClipRate -= dtime;
if (playerBonus.nextNoClipRate <= 0ns) {
if (playerBonus.nextNoClipRate <= 0ns && playerBonus.isNoClipOn) {
playerBonus.nextNoClipRate = playerBonus.noClipBonusRate;
playerBonus.isNoClipOn = false;
auto playerPos = entity->tryGetComponent<PositionComponent>();
auto playerHealth = entity->tryGetComponent<HealthComponent>();
if (!playerHealth || !playerPos)
return;
for (auto &[other, pos, _] : this->_wal.getScene()->view<PositionComponent, TagComponent<Blowable>>()) {
auto vec = (playerPos->position - pos.position).abs();
if (vec.x < 0.65 && vec.z < 0.65 && playerPos->position.distance(pos.position) < 1)
playerHealth->takeDmg(playerHealth->getHealthPoint());
}
}
}
}
@@ -1,6 +1,7 @@
#include "EndConditionSystem.hpp"
#include <map>
#include <System/Renderer/CameraSystem.hpp>
#include "Runner/Runner.hpp"
#include "Component/Score/ScoreComponent.hpp"
@@ -23,6 +24,7 @@ namespace BBM
if (alivePlayersCount <= 1) {
endConditionRate -= dtime;
if (endConditionRate <= 0ns) {
this->_wal.getSystem<CameraSystem>().hasEnded = false;
Runner::gameState.nextScene = Runner::gameState.ScoreScene;
endConditionRate = 500ms;
}
+4 -4
View File
@@ -27,13 +27,13 @@ namespace BBM
Gamepad gamepad(gamepadComponent.getID());
const std::map<Button, bool &> keyPressedMap = {
{gamepadComponent.keyJump, controllable.select},
{gamepadComponent.keyBomb, controllable.bomb},
{gamepadComponent.keyPause, controllable.pause}
{gamepadComponent.keySecondary, controllable.secondary},
{gamepadComponent.keyBomb, controllable.bomb},
{gamepadComponent.keyPause, controllable.pause}
};
for (auto key : keyPressedMap)
key.second = gamepad.isDown(key.first);
key.second = controllable.fastClick ? gamepad.isDown(key.first) : gamepad.isPressed(key.first);
controllable.move.x = gamepad.getAxisValue(gamepadComponent.LeftStickX) * -1;
controllable.move.y = gamepad.getAxisValue(gamepadComponent.LeftStickY) * -1;
controllable.move.x -= static_cast<float>(gamepad.isDown(gamepadComponent.keyRight));
@@ -169,7 +169,7 @@ namespace BBM
pushInfo(ia._state, player, bombHolder);
ia._state.callFunction(1, 4);
controllable.bomb = ia._state.getReturnBool();
controllable.select = ia._state.getReturnBool();
controllable.secondary = ia._state.getReturnBool();
controllable.move.y = ia._state.getReturnNumber();
controllable.move.x = ia._state.getReturnNumber();
ia._state.popLast();
+4 -4
View File
@@ -25,13 +25,13 @@ namespace BBM
return;
const std::map<KeyboardKey, bool &> keyPressedMap = {
{keyboard.keyJump, controllable.select},
{keyboard.keyBomb, controllable.bomb},
{keyboard.keyPause, controllable.pause}
{keyboard.keySecondary, controllable.secondary},
{keyboard.keyBomb, controllable.bomb},
{keyboard.keyPause, controllable.pause}
};
for (auto key : keyPressedMap)
key.second = Keyboard::isDown(key.first);
key.second = controllable.fastClick ? Keyboard::isDown(key.first) : Keyboard ::isPressed(key.first);
controllable.move = Vector2f();
if (Keyboard::isDown(keyboard.keyRight))
controllable.move.x -= 1;
+6 -6
View File
@@ -77,7 +77,7 @@ namespace BBM
if (lobby.layout == ControllableComponent::NONE) {
for (auto &[_, ctrl] : this->_wal.getScene()->view<ControllableComponent>()) {
auto &controller = ctrl;
if (controller.select) {
if (controller.bomb) {
if (std::any_of(this->getView().begin(), this->getView().end(), [&controller](WAL::ViewEntity<LobbyComponent, Drawable2DComponent> &view) {
return view.get<LobbyComponent>().layout == controller.layout;
}))
@@ -86,7 +86,7 @@ namespace BBM
lobby.color = -1;
this->_nextColor(entity);
lobby.layout = controller.layout;
controller.select = false;
controller.bomb = false;
return;
}
}
@@ -95,16 +95,16 @@ namespace BBM
for (auto &[_, controller] : this->_wal.getScene()->view<ControllableComponent>()) {
if (controller.layout != lobby.layout)
continue;
if (controller.select && !lobby.ready) {
if (controller.bomb && !lobby.ready) {
lobby.ready = true;
lobby.lastInput = lastTick;
controller.select = false;
controller.bomb = false;
this->_wal.getSystem<MenuControllableSystem>().now = lastTick;
auto *texture = dynamic_cast<RAY::Texture *>(lobby.readyButton.getComponent<Drawable2DComponent>().drawable.get());
if (texture)
texture->use("assets/player/icons/ready.png");
}
if (controller.bomb && !lobby.ready) {
if (controller.secondary && !lobby.ready) {
lobby.lastInput = lastTick;
this->_nextColor(entity);
}
@@ -295,7 +295,7 @@ namespace BBM
createTile(scene, player, lobby.color, playerCount);
playerCount++;
}
Runner::gameState._loadedScenes[GameState::SceneID::GameScene] = scene;
Runner::gameState.loadedScenes[GameState::SceneID::GameScene] = scene;
MapGenerator::loadMap(Runner::mapWidth, Runner::mapHeight, MapGenerator::createMap(Runner::mapWidth, Runner::mapHeight, Runner::hasHeights), scene);
Runner::gameState.nextScene = BBM::GameState::SceneID::GameScene;
wal.getSystem<LobbySystem>().unloadLobby();
+3 -3
View File
@@ -45,7 +45,7 @@ namespace BBM
if (lobby.layout == ControllableComponent::NONE) {
for (auto &[_, ctrl] : this->_wal.getScene()->view<ControllableComponent>()) {
auto &controller = ctrl;
if (controller.select) {
if (controller.bomb) {
if (std::any_of(this->getView().begin(), this->getView().end(), [&controller](WAL::ViewEntity<ResumeLobbyComponent, Drawable2DComponent> &view) {
return view.get<ResumeLobbyComponent>().layout == controller.layout;
}))
@@ -53,7 +53,7 @@ namespace BBM
lobby.ready = true;
lobby.lastInput = lastTick;
lobby.layout = controller.layout;
controller.select = false;
controller.bomb = false;
this->_wal.getSystem<MenuControllableSystem>().now = lastTick;
auto *texture = dynamic_cast<RAY::Texture *>(lobby.readyButton.getComponent<Drawable2DComponent>().drawable.get());
if (texture)
@@ -89,7 +89,7 @@ namespace BBM
void ResumeLobbySystem::resumeToGame(WAL::Wal &wal)
{
auto scene = Runner::gameState._loadedScenes[GameState::SceneID::GameScene];
auto scene = Runner::gameState.loadedScenes[GameState::SceneID::GameScene];
int countPlayer = 0;
for (auto &[_, lobby] : wal.getScene()->view<ResumeLobbyComponent>()) {
@@ -55,24 +55,24 @@ namespace BBM
bool MenuControllableSystem::_mouseOnButton(const Vector2f &mousePos, WAL::ViewEntity<OnClickComponent, OnHoverComponent, OnIdleComponent, PositionComponent, Drawable2DComponent> &entity) const
{
auto &positionComponent = entity.get<PositionComponent>();
RAY::Texture *texture = dynamic_cast<RAY::Texture *>(entity.get<Drawable2DComponent>().drawable.get());
RAY2D::Text *text = dynamic_cast<RAY2D::Text *>(entity.get<Drawable2DComponent>().drawable.get());
Vector2f buttonPos(positionComponent.getX(), positionComponent.getY());
Vector2f dimensions;
if (texture) {
if (auto *texture = dynamic_cast<RAY::Texture *>(entity.get<Drawable2DComponent>().drawable.get())) {
dimensions.x = texture->getDimensions().x;
dimensions.y = texture->getDimensions().y;
} else if (text) {
}
else if (auto *text = dynamic_cast<RAY2D::Text *>(entity.get<Drawable2DComponent>().drawable.get())) {
dimensions.y = text->getFontSize();
dimensions.x = text->getString().size() * (text->getFontSize());
} else
}
else
return false;
return ((buttonPos.x <= mousePos.x && mousePos.x <= buttonPos.x + dimensions.x)
&& (buttonPos.y <= mousePos.y && mousePos.y <= buttonPos.y + dimensions.y));
&& (buttonPos.y <= mousePos.y && mousePos.y <= buttonPos.y + dimensions.y));
}
void MenuControllableSystem::onSelfUpdate(std::chrono::nanoseconds dtime)
void MenuControllableSystem::onSelfUpdate(std::chrono::nanoseconds)
{
RAY::Vector2 rayMousePos = RAYControl::Mouse::getCursorPosition();
RAY::Vector2 winSize = RAY::Window::getInstance().getDimensions();
@@ -95,8 +95,8 @@ namespace BBM
if (!this->_currentButton)
return;
for (auto &[_, controllable]: controllableView)
if (controllable.move.x || controllable.move.y || controllable.select) {
this->_updateCurrentButton(controllable.select, controllable.move);
if (controllable.move.x || controllable.move.y || controllable.bomb) {
this->_updateCurrentButton(controllable.bomb, controllable.move);
return;
}
if (relativeMousePos == this->_oldMousePosition && !RAYControl::Mouse::isPressed(RAYControl::Mouse::Button::MOUSE_BUTTON_LEFT))
+15 -7
View File
@@ -8,6 +8,7 @@
#include "Component/Timer/TimerComponent.hpp"
#include "Runner/Runner.hpp"
#include "Component/Renderer/Drawable2DComponent.hpp"
#include "Component/Movable/MovableComponent.hpp"
#include "Drawables/2D/Text.hpp"
namespace RAY2D = RAY::Drawables::Drawables2D;
@@ -31,9 +32,11 @@ namespace BBM
.addComponent<PositionComponent>(1920 / 2 - 2 * 30 - 20, 28, 0)
.addComponent<Drawable2DComponent, RAY2D::Rectangle>(Vector2f(), Vector2f(150, 60), RAY::Color(BLACK).setA(150));
this->_wal.getScene()->scheduleNewEntity("Timer")
.addComponent<TimerComponent>(std::chrono::minutes (3), [](WAL::Entity &, WAL::Wal &) {
.addComponent<TimerComponent>(std::chrono::minutes (3), [](WAL::Entity &, WAL::Wal &engine) {
engine.getSystem<CameraSystem>().hasEnded = false;
Runner::gameState.nextScene = GameState::ScoreScene;
})
.addComponent<TagComponent<"Timer">>()
.addComponent<PositionComponent>(1920 / 2 - 2 * 30, 30, 0)
.addComponent<TagComponent<Timer>>()
.addComponent<Drawable2DComponent, RAY2D::Text>("", 60, RAY::Vector2(), ORANGE);
@@ -60,8 +63,6 @@ namespace BBM
float lowerZDist = 0;
for (auto &[player, position, _] : this->_wal.getScene()->view<PositionComponent, TagComponent<Player>>()) {
if (!player.hasComponent<ControllableComponent>())
player.addComponent<ControllableComponent>();
playerPos.emplace_back(position.position);
}
if (playerPos.size() == 1)
@@ -80,11 +81,18 @@ namespace BBM
maxDist += (lowerXDist + lowerZDist) / 2;
if (maxDist < 14)
maxDist = 14;
if (maxDist > 25)
maxDist = 25;
cam.target += (newCameraPos.abs() - pos.position.abs()) / 10;
if (maxDist > 23)
maxDist = 23;
Vector3f pos2d(pos.position.abs().x,0, pos.position.abs().z);
Vector3f newPos2d(newCameraPos.abs().x, 0, pos.position.abs().z);
for (auto &[other, backPos, _] : this->_wal.getScene()->view<PositionComponent, TagComponent<Background>>()) {
backPos.position = cam.target;
}
newCameraPos.y = 0;
cam.target += (newCameraPos.abs() - cam.target.abs()) / 10;
newCameraPos.y = maxDist;
newCameraPos.z -= 1;
newCameraPos.z -= newCameraPos.z > 1 ? 1 : 0;
pos.position += (newCameraPos.abs() - pos.position.abs()) / 10;
}
}
@@ -20,7 +20,7 @@ namespace BBM {
std::map<bool, SoundComponent::SoundIndex> soundIndex = {
{controllable.move.x, SoundComponent::MOVE},
{controllable.move.y, SoundComponent::MOVE},
{controllable.select, SoundComponent::JUMP},
{controllable.bomb, SoundComponent::BOMB},
};
for (auto &a : soundIndex) {
if (a.first) {
@@ -21,7 +21,6 @@ namespace BBM {
std::map<bool, SoundComponent::SoundIndex> soundIndex = {
{health.getHealthPoint() <= 0, SoundComponent::DEATH},
{controllable.bomb, SoundComponent::BOMB},
{controllable.select, SoundComponent::JUMP},
{controllable.move.x != 0 || controllable.move.y != 0, SoundComponent::MOVE}
};
for (auto &a : soundIndex) {
+5
View File
@@ -17,8 +17,13 @@ namespace BBM
void TimerSystem::onUpdate(WAL::ViewEntity<TimerComponent> &entity, std::chrono::nanoseconds dtime)
{
auto &timer = entity.get<TimerComponent>();
if (timer.disabled)
return;
timer.ringIn -= dtime;
if (timer.ringIn <= 0ns) {
timer.disabled = true;
timer.callback(entity, this->_wal);
}
}