This commit is contained in:
2024-10-03 20:09:10 -05:00
parent 2ff1a159bc
commit ad317da97e
303 changed files with 1613 additions and 21403 deletions

View File

@ -1,9 +0,0 @@
# Copyright (c) 2022 Dominic Masters
#
# This software is released under the MIT License.
# https://opensource.org/licenses/MIT
target_sources(${DAWN_TARGET_NAME}
PRIVATE
Game.cpp
)

View File

@ -1,56 +0,0 @@
// Copyright (c) 2023 Dominic Masters
//
// This software is released under the MIT License.
// https://opensource.org/licenses/MIT
#include "game/Game.hpp"
#include "game/GameInit.hpp"
#include "scene/Scene.hpp"
using namespace Dawn;
Game::Game() {
}
void Game::init() {
renderHost.init(shared_from_this());
inputManager.init(shared_from_this());
saveManager.init(shared_from_this());
auto initialScene = Scene::getInitialScene();
this->nextFrameScene = std::make_shared<Scene>(shared_from_this(), initialScene);
}
void Game::update() {
this->assetManager.update();
if(nextFrameScene) {
nextFrameScene->stage();
currentScene = nextFrameScene;
nextFrameScene = nullptr;
}
timeManager.update();
inputManager.update();
if(currentScene) currentScene->update();
renderHost.update(shared_from_this());
}
bool_t Game::isCloseRequested() {
return (
renderHost.isCloseRequested()
);
}
std::shared_ptr<Scene> Game::getCurrentScene() {
return currentScene;
}
Game::~Game() {
currentScene = nullptr;
nextFrameScene = nullptr;
assertTrue(SCENE_ITEMS_ACTIVE == 0, "Some scene items are still active?");
assertTrue(SCENE_COMPONENTS_ACTIVE == 0, "Some scene components are still active?");
}

View File

@ -1,67 +0,0 @@
// Copyright (c) 2023 Dominic Masters
//
// This software is released under the MIT License.
// https://opensource.org/licenses/MIT
#pragma once
#include "dawnlibs.hpp"
#include "display/RenderHost.hpp"
#include "input/InputManager.hpp"
#include "time/TimeManager.hpp"
#include "asset/AssetManager.hpp"
#include "locale/LocaleManager.hpp"
#include "save/SaveManager.hpp"
namespace Dawn {
class Scene;
class Game : public std::enable_shared_from_this<Game> {
private:
std::shared_ptr<Scene> currentScene = nullptr;
std::shared_ptr<Scene> nextFrameScene = nullptr;
public:
RenderHost renderHost;
InputManager inputManager;
TimeManager timeManager;
AssetManager assetManager;
LocaleManager localeManager;
SaveManager saveManager;
/**
* Constructs the game instance, does not initialize anything.
*/
Game();
/**
* Initialize the game and all of its components.
*/
void init();
/**
* Performs a single update tick on the game engine, and in turn all of
* the game's sub systems.
*/
void update();
/**
* Returns whether the game has been requested to gracefully close at the
* next available opportunity.
*
* @return True if the game should close.
*/
bool_t isCloseRequested();
/**
* Returns the current scene that is active.
*
* @return The current scene.
*/
std::shared_ptr<Scene> getCurrentScene();
/**
* Deconstructs the game instance, does not deinitialize anything.
*/
virtual ~Game();
};
}

View File

@ -1,15 +0,0 @@
// 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();
};
}