2023-07-31 06:01:51 +00:00
|
|
|
#include "game.h"
|
|
|
|
|
2023-07-31 07:27:01 +00:00
|
|
|
// local includes
|
|
|
|
#include "screen_test.h"
|
2023-07-31 06:01:51 +00:00
|
|
|
|
2023-07-31 06:41:09 +00:00
|
|
|
Game::Game()
|
2023-07-31 07:27:01 +00:00
|
|
|
: screen_stack(ScreenStack::new_instance()),
|
2023-07-31 11:39:46 +00:00
|
|
|
prev_time(std::chrono::steady_clock::now()) {}
|
2023-07-31 06:01:51 +00:00
|
|
|
|
2023-07-31 06:41:09 +00:00
|
|
|
void Game::update() {
|
|
|
|
auto next_time = std::chrono::steady_clock::now();
|
|
|
|
auto duration = std::chrono::duration_cast<std::chrono::microseconds>(
|
|
|
|
next_time - prev_time);
|
|
|
|
prev_time = next_time;
|
2023-07-31 07:27:01 +00:00
|
|
|
screen_stack->update(((float)duration.count()) / 1000000);
|
2023-07-31 06:28:01 +00:00
|
|
|
}
|
2023-07-31 06:41:09 +00:00
|
|
|
|
2023-07-31 07:27:01 +00:00
|
|
|
void Game::draw() { screen_stack->draw(); }
|