Fixing the pause timer

This commit is contained in:
Zoe Roux
2021-06-20 12:17:43 +02:00
parent c518de097a
commit de6bdf61fe
2 changed files with 9 additions and 4 deletions
+1
View File
@@ -126,6 +126,7 @@ namespace BBM
if (!ent.hasComponent<SoundComponent>())
return;
ent.removeComponent<SoundComponent>();
ent.removeComponent<HealthComponent>();
ent.removeComponent<CollisionComponent>();
ent.removeComponent<PositionComponent>();
});
+8 -4
View File
@@ -1,5 +1,4 @@
#include <memory>
#include <Wal.hpp>
#include "Runner.hpp"
#include <map>
@@ -59,6 +58,10 @@ namespace BBM
.addComponent<OnClickComponent>([](WAL::Entity &, WAL::Wal &)
{
auto &gameScene = gameState.loadedScenes[BBM::GameState::SceneID::GameScene];
for (WAL::Entity &entity : gameScene->view<TagComponent<"RestartTimer">>())
entity.scheduleDeletion();
for (auto &[entity, controller, _] : gameScene->view<ControllableComponent, HealthComponent>()) {
controller.disabled = true;
controller.pause = false;
@@ -78,6 +81,7 @@ namespace BBM
})
.addComponent<PositionComponent>(1920 / 2 - 2 * 30, 1080 / 2, 0)
.addComponent<TagComponent<Timer>>()
.addComponent<TagComponent<"RestartTimer">>()
.addComponent<Drawable2DComponent, RAY2D::Text>("", 60, RAY::Vector2(), ORANGE);
gameState.nextScene = BBM::GameState::SceneID::GameScene;
});
@@ -86,17 +90,17 @@ namespace BBM
.addComponent<Drawable2DComponent, RAY::Texture>("assets/buttons/button_save.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_save.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_save_hovered.png");
})
.addComponent<OnClickComponent>([](WAL::Entity &entity, WAL::Wal &wal)
.addComponent<OnClickComponent>([](WAL::Entity &, WAL::Wal &wal)
{
if (!std::filesystem::exists("save"))
std::filesystem::create_directories("save");