diff --git a/index.html b/index.html deleted file mode 100644 index 33921223..00000000 --- a/index.html +++ /dev/null @@ -1,30 +0,0 @@ - - - - - Home - - - - -

Hello Emscripten

- - - - - - - diff --git a/src/dawn/event/Event.hpp b/src/dawn/event/Event.hpp new file mode 100644 index 00000000..6fce0ba9 --- /dev/null +++ b/src/dawn/event/Event.hpp @@ -0,0 +1,20 @@ +// Copyright (c) 2023 Dominic Masters +// +// This software is released under the MIT License. +// https://opensource.org/licenses/MIT + +#pragma once +#include "dawnlibs.hpp" + +namespace Dawn { + template + class Event { + private: + + public: + Event() {} + virtual ~Event() {} + + virtual void operator()(T &t) = 0; + } +} \ No newline at end of file diff --git a/src/dawn/game/Game.cpp b/src/dawn/game/Game.cpp index efc33649..7724fc8c 100644 --- a/src/dawn/game/Game.cpp +++ b/src/dawn/game/Game.cpp @@ -21,7 +21,8 @@ void Game::init() { nextFrameScene = std::make_shared(shared_from_this(), initialScene); } -void Game::update(float_t delta) { +void Game::update() { + timeManager.update(); renderHost.update(shared_from_this()); if(nextFrameScene) { diff --git a/src/dawn/time/ITimeManager.cpp b/src/dawn/time/ITimeManager.cpp index f3c8a620..e780fac7 100644 --- a/src/dawn/time/ITimeManager.cpp +++ b/src/dawn/time/ITimeManager.cpp @@ -7,11 +7,6 @@ using namespace Dawn; -void ITimeManager::tick(float_t delta) { - this->delta = delta; - this->time += delta; -} - ITimeManager::~ITimeManager() { } \ No newline at end of file diff --git a/src/dawn/time/ITimeManager.hpp b/src/dawn/time/ITimeManager.hpp index 657305b7..b0e7fc8b 100644 --- a/src/dawn/time/ITimeManager.hpp +++ b/src/dawn/time/ITimeManager.hpp @@ -14,10 +14,8 @@ namespace Dawn { /** * Ticks / updates the time management system. - * - * @param delta Time delta in seconds. */ - void tick(float_t delta); + virtual void update() = 0; /** * Returns the real world time epoch. diff --git a/src/dawnglfw/time/TimeManager.cpp b/src/dawnglfw/time/TimeManager.cpp index 674c2afb..28bc536a 100644 --- a/src/dawnglfw/time/TimeManager.cpp +++ b/src/dawnglfw/time/TimeManager.cpp @@ -4,6 +4,7 @@ // https://opensource.org/licenses/MIT #include "TimeManager.hpp" +#include #include #include #include @@ -11,6 +12,19 @@ using namespace Dawn; +TimeManager::TimeManager() { + lastUpdate = glfwGetTime(); +} + +void TimeManager::update() { + double_t newTime = glfwGetTime(); + delta = ( + (float_t)(newTime - lastUpdate) + ); + time += delta; + lastUpdate = newTime; +} + int64_t TimeManager::getRealTime() { auto millisec_since_epoch = std::chrono::duration_cast(std::chrono::system_clock::now().time_since_epoch()) .count(); return millisec_since_epoch; diff --git a/src/dawnglfw/time/TimeManager.hpp b/src/dawnglfw/time/TimeManager.hpp index ba49d5cf..4b434502 100644 --- a/src/dawnglfw/time/TimeManager.hpp +++ b/src/dawnglfw/time/TimeManager.hpp @@ -8,7 +8,15 @@ namespace Dawn { class TimeManager : public ITimeManager { + private: + double_t lastUpdate = 0; public: + /** + * Constructs and initializes the TimeManager. + */ + TimeManager(); + + void update() override; int64_t getRealTime() override; }; } \ No newline at end of file