New scene items system
This commit is contained in:
@ -3,7 +3,9 @@
|
||||
// This software is released under the MIT License.
|
||||
// https://opensource.org/licenses/MIT
|
||||
|
||||
#include "Game.hpp"
|
||||
#include "game/Game.hpp"
|
||||
#include "game/GameInit.hpp"
|
||||
#include "scene/Scene.hpp"
|
||||
|
||||
using namespace Dawn;
|
||||
|
||||
@ -12,12 +14,21 @@ Game::Game() {
|
||||
}
|
||||
|
||||
void Game::init() {
|
||||
renderHost.init();
|
||||
renderHost.init(shared_from_this());
|
||||
inputManager.init(shared_from_this());
|
||||
|
||||
auto initialScene = GameInit::getInitialScene();
|
||||
nextFrameScene = std::make_shared<Scene>(shared_from_this(), initialScene);
|
||||
}
|
||||
|
||||
void Game::update() {
|
||||
renderHost.update();
|
||||
|
||||
if(nextFrameScene) {
|
||||
nextFrameScene->stage();
|
||||
currentScene = nextFrameScene;
|
||||
nextFrameScene = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
bool_t Game::isCloseRequested() {
|
||||
@ -27,5 +38,5 @@ bool_t Game::isCloseRequested() {
|
||||
}
|
||||
|
||||
Game::~Game() {
|
||||
|
||||
std::cout << "Game successfully destructed" << std::endl;
|
||||
}
|
@ -9,7 +9,13 @@
|
||||
#include "input/InputManager.hpp"
|
||||
|
||||
namespace Dawn {
|
||||
class Scene;
|
||||
|
||||
class Game : public std::enable_shared_from_this<Game> {
|
||||
private:
|
||||
std::shared_ptr<Scene> currentScene;
|
||||
std::shared_ptr<Scene> nextFrameScene;
|
||||
|
||||
public:
|
||||
RenderHost renderHost;
|
||||
InputManager inputManager;
|
||||
|
15
src/dawn/game/GameInit.hpp
Normal file
15
src/dawn/game/GameInit.hpp
Normal file
@ -0,0 +1,15 @@
|
||||
// Copyright (c) 2023 Dominic Masters
|
||||
//
|
||||
// This software is released under the MIT License.
|
||||
// https://opensource.org/licenses/MIT
|
||||
|
||||
#pragma once
|
||||
#include "game/Game.hpp"
|
||||
#include "scene/Scene.hpp"
|
||||
|
||||
namespace Dawn {
|
||||
class GameInit {
|
||||
public:
|
||||
static std::function<void(Scene&)> getInitialScene();
|
||||
};
|
||||
}
|
Reference in New Issue
Block a user