Allowing the window to be closed

This commit is contained in:
Zoe Roux
2021-05-27 23:08:48 +02:00
parent b88172b667
commit 47359e2a14
3 changed files with 8 additions and 4 deletions
+3 -3
View File
@@ -23,8 +23,6 @@ namespace WAL
private:
//! @brief The list of registered systems
std::vector<std::unique_ptr<System>> _systems = {};
//! @brief True if the engine should close after the end of the current tick.
bool _shouldClose = false;
//! @brief Call the onUpdate of every system with every component
void _update(std::chrono::nanoseconds dtime);
@@ -40,6 +38,8 @@ namespace WAL
public:
//! @brief The scene that contains entities.
std::shared_ptr<Scene> scene;
//! @brief True if the engine should close after the end of the current tick.
bool shouldClose = false;
//! @brief The time between each fixed update.
static std::chrono::nanoseconds timestep;
@@ -122,7 +122,7 @@ namespace WAL
auto lastTick = std::chrono::steady_clock::now();
std::chrono::nanoseconds fBehind(0);
while (!this->_shouldClose) {
while (!this->shouldClose) {
auto now = std::chrono::steady_clock::now();
std::chrono::nanoseconds dtime = now - lastTick;
fBehind += dtime;
+4
View File
@@ -10,6 +10,7 @@
#include <System/Renderer/Renderer2DSystem.hpp>
#include <Model/Model.hpp>
#include <Drawables/2D/Rectangle.hpp>
#include <TraceLog.hpp>
#include <System/Renderer/Renderer3DSystem.hpp>
#include "Models/Vector2.hpp"
#include "Component/Renderer/CameraComponent.hpp"
@@ -27,10 +28,13 @@ namespace BBM
// If you want to keep a scene loaded but not running, store it in the state.loadedScenes.
// If you don't need the scene anymore, remember to remove it from the loadedScene array.
if (RAY::Window::getInstance().shouldClose())
engine.shouldClose = true;
}
void enableRaylib(WAL::Wal &wal)
{
RAY::TraceLog::setLevel(LOG_WARNING);
RAY::Window &window = RAY::Window::getInstance(600, 400, "Bomberman", FLAG_WINDOW_RESIZABLE);
wal.addSystem<Renderer3DSystem<RAY3D::Model>>();
+1 -1
View File
@@ -52,7 +52,7 @@ int demo()
const int screenHeight = 450;
auto iterator = textures.begin();
const std::string modelPath = "assets/player/player.iqm";
// RAY::TraceLog::setLevel(LOG_WARNING);
RAY::TraceLog::setLevel(LOG_WARNING);
RAY::Window &window = RAY::Window::getInstance(screenWidth, screenHeight, "Bidibidibop", FLAG_WINDOW_RESIZABLE);
RAY::Image icon("assets/icon.png");
RAY::Drawables::Drawables3D::Model model(modelPath, std::pair(MAP_DIFFUSE, "assets/player/blue.png"));