mirror of
https://github.com/zoriya/Bomberman.git
synced 2026-06-04 18:46:22 +00:00
Adding a scene manger and wal functions
This commit is contained in:
@@ -0,0 +1,5 @@
|
||||
//
|
||||
// Created by Zoe Roux on 2021-05-14.
|
||||
//
|
||||
|
||||
#include "Scene.hpp"
|
||||
@@ -0,0 +1,20 @@
|
||||
//
|
||||
// Created by Zoe Roux on 2021-05-14.
|
||||
//
|
||||
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <vector>
|
||||
#include "Entity/Entity.hpp"
|
||||
|
||||
namespace WAL
|
||||
{
|
||||
//! @brief Represent a single scene that contains entities.
|
||||
class Scene
|
||||
{
|
||||
private:
|
||||
//! @brief The list of registered entities
|
||||
std::vector<Entity> _entity;
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
//
|
||||
// Created by Zoe Roux on 2021-05-14.
|
||||
//
|
||||
|
||||
#include "SceneManager.hpp"
|
||||
|
||||
namespace WAL
|
||||
{
|
||||
SceneManager &WAL::SceneManager::addScene(WAL::Scene &&scene)
|
||||
{
|
||||
this->_scenes.push_front(scene);
|
||||
return *this;
|
||||
}
|
||||
|
||||
SceneManager &SceneManager::addBackScene(Scene &&scene)
|
||||
{
|
||||
this->_scenes.insert(++this->_scenes.begin(), scene);
|
||||
return *this;
|
||||
}
|
||||
|
||||
Scene &SceneManager::getCurrent()
|
||||
{
|
||||
return this->_scenes.front();
|
||||
}
|
||||
|
||||
SceneManager &SceneManager::closeCurrent()
|
||||
{
|
||||
this->_scenes.pop_front();
|
||||
return *this;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
//
|
||||
// Created by Zoe Roux on 2021-05-14.
|
||||
//
|
||||
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <queue>
|
||||
#include "Scene/Scene.hpp"
|
||||
|
||||
namespace WAL
|
||||
{
|
||||
//! @brief A class to manage scenes
|
||||
class SceneManager
|
||||
{
|
||||
private:
|
||||
std::deque<Scene> _scenes = {};
|
||||
public:
|
||||
//! @brief Add a scene to the container and move to it.
|
||||
//! @return The manager instance used to call this function is returned. This allow method chaining.
|
||||
SceneManager &addScene(Scene &&scene);
|
||||
|
||||
//! @brief Add a scene before the current scene to allow
|
||||
//! @return The manager instance used to call this function is returned. This allow method chaining.
|
||||
SceneManager &addBackScene(Scene &&scene);
|
||||
|
||||
//! @breif Get the current scene
|
||||
Scene &getCurrent();
|
||||
|
||||
//! @brief Remove the current scene and switch to the previous scene on the stack.
|
||||
//! @return The manager instance used to call this function is returned. This allow method chaining.
|
||||
SceneManager &closeCurrent();
|
||||
|
||||
//! @brief A default constructor
|
||||
SceneManager() = default;
|
||||
//! @brief A scene manager is copy constructable
|
||||
SceneManager(const SceneManager &) = default;
|
||||
//! @brief A default destructor.
|
||||
~SceneManager() = default;
|
||||
//! @brief A scene manager is assignable
|
||||
SceneManager &operator=(const SceneManager &) = default;
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user