New scene items system

This commit is contained in:
2023-11-15 18:56:25 -06:00
parent 1817dcaf3a
commit 6c6203a41d
38 changed files with 1309 additions and 36 deletions

View File

@ -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;
}

View File

@ -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;

View 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();
};
}