Simplified DawnGAme a lot
This commit is contained in:
10
src/dawn/game/CMakeLists.txt
Normal file
10
src/dawn/game/CMakeLists.txt
Normal file
@ -0,0 +1,10 @@
|
||||
# Copyright (c) 2023 Dominic Masters
|
||||
#
|
||||
# This software is released under the MIT License.
|
||||
# https://opensource.org/licenses/MIT
|
||||
|
||||
# Sources
|
||||
target_sources(${DAWN_TARGET_NAME}
|
||||
PRIVATE
|
||||
DawnGame.cpp
|
||||
)
|
42
src/dawn/game/DawnGame.cpp
Normal file
42
src/dawn/game/DawnGame.cpp
Normal file
@ -0,0 +1,42 @@
|
||||
// Copyright (c) 2023 Dominic Masters
|
||||
//
|
||||
// This software is released under the MIT License.
|
||||
// https://opensource.org/licenses/MIT
|
||||
|
||||
#include "DawnGame.hpp"
|
||||
|
||||
using namespace Dawn;
|
||||
|
||||
DawnGame::DawnGame(DawnHost *host) :
|
||||
host(host),
|
||||
renderManager(this),
|
||||
inputManager(this),
|
||||
saveManager(this)
|
||||
{
|
||||
}
|
||||
|
||||
int32_t DawnGame::init() {
|
||||
this->assetManager.init();
|
||||
this->renderManager.init();
|
||||
|
||||
this->scene = dawnGameGetInitialScene(this);
|
||||
|
||||
return DAWN_GAME_INIT_RESULT_SUCCESS;
|
||||
}
|
||||
|
||||
int32_t DawnGame::update(float_t delta) {
|
||||
this->assetManager.update();
|
||||
this->inputManager.update();
|
||||
this->timeManager.update(delta);
|
||||
|
||||
if(this->scene != nullptr) this->scene->update();
|
||||
|
||||
this->renderManager.update();
|
||||
|
||||
return DAWN_GAME_UPDATE_RESULT_SUCCESS;
|
||||
}
|
||||
|
||||
void DawnGame::sceneCutover(Scene *scene) {
|
||||
if(scene == nullptr) scene = this->scene;
|
||||
this->sceneToCutTo = scene;
|
||||
}
|
@ -22,12 +22,25 @@
|
||||
namespace Dawn {
|
||||
class DawnHost;
|
||||
|
||||
class IDawnGame {
|
||||
protected:
|
||||
// SceneItemComponentList componentList;
|
||||
class DawnGame {
|
||||
private:
|
||||
Scene *sceneToCutTo = nullptr;
|
||||
|
||||
public:
|
||||
DawnHost *host;
|
||||
Scene *scene = nullptr;
|
||||
AssetManager assetManager;
|
||||
TimeManager timeManager;
|
||||
RenderManager renderManager;
|
||||
InputManager inputManager;
|
||||
SaveManager saveManager;
|
||||
|
||||
/**
|
||||
* Construct a new game instance.
|
||||
*
|
||||
* @param host Host that executed this game instantiation.
|
||||
*/
|
||||
DawnGame(DawnHost *host);
|
||||
|
||||
/**
|
||||
* Initialize the game. This is performed by the host at a time that is
|
||||
@ -38,7 +51,7 @@ namespace Dawn {
|
||||
* @param host Pointer to the host that is running this game.
|
||||
* @return The game initialize result.
|
||||
*/
|
||||
virtual int32_t init() = 0;
|
||||
int32_t init();
|
||||
|
||||
/**
|
||||
* Performs a game update operation. This operation should occur exactly
|
||||
@ -52,7 +65,7 @@ namespace Dawn {
|
||||
* @param delta Time delta to tick the game by.
|
||||
* @return The game update result.
|
||||
*/
|
||||
virtual int32_t update(float_t delta) = 0;
|
||||
int32_t update(float_t delta);
|
||||
|
||||
/**
|
||||
* Changes to a new scene, will dispose the currently active scene as part
|
||||
@ -61,13 +74,15 @@ namespace Dawn {
|
||||
*
|
||||
* @param scene Scene to cut over to.
|
||||
*/
|
||||
virtual void sceneCutover(Scene *scene) = 0;
|
||||
|
||||
/**
|
||||
* Cleanup the memory of the DawnGame instance.
|
||||
*/
|
||||
virtual ~IDawnGame() {
|
||||
|
||||
}
|
||||
void sceneCutover(Scene *scene);
|
||||
};
|
||||
|
||||
/**
|
||||
* Unimplemented by default, required by the game as the basic entry point
|
||||
* for which scene should be used by default.
|
||||
*
|
||||
* @param game Game that is requesting this scene.
|
||||
* @return Pointer to a scene that you wish to have as the default scene.
|
||||
*/
|
||||
Scene * dawnGameGetInitialScene(DawnGame *game);
|
||||
}
|
Reference in New Issue
Block a user