2023-07-31 06:01:51 +00:00
|
|
|
#include "game.h"
|
|
|
|
|
2023-07-31 07:27:01 +00:00
|
|
|
// local includes
|
2023-08-02 10:59:06 +00:00
|
|
|
#include "screen_trunner.h"
|
2023-07-31 06:01:51 +00:00
|
|
|
|
2023-08-09 04:39:43 +00:00
|
|
|
// third party includes
|
|
|
|
#include <raymath.h>
|
|
|
|
|
2023-07-31 06:41:09 +00:00
|
|
|
Game::Game()
|
2023-07-31 07:27:01 +00:00
|
|
|
: screen_stack(ScreenStack::new_instance()),
|
2023-08-02 10:59:06 +00:00
|
|
|
prev_time(std::chrono::steady_clock::now()) {
|
|
|
|
screen_stack->push_screen<TRunnerScreen>();
|
|
|
|
}
|
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-08-09 04:39:43 +00:00
|
|
|
screen_stack->update(Clamp(((float)duration.count()) / 1000000, 0.0F, 1.0F));
|
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(); }
|