-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathmain.cpp
More file actions
33 lines (30 loc) · 919 Bytes
/
main.cpp
File metadata and controls
33 lines (30 loc) · 919 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#include "Game.h"
#include <chrono>
#include <iostream>
Game game;
int main() {
bool running = true;
if (!game.Init())
{
return EXIT_FAILURE;
}
game.SetRunning(running);
auto lastFrameTime = std::chrono::high_resolution_clock::now();
while (running)
{
std::chrono::high_resolution_clock::time_point currentFrameTime = std::chrono::high_resolution_clock::now();
double duration = (double)std::chrono::duration_cast<std::chrono::nanoseconds>(currentFrameTime - lastFrameTime).count();
float deltaTime = (float)(0.000000001 * duration);
lastFrameTime = currentFrameTime;
try {
game.Update(deltaTime);
game.DrawFrame();
}
catch (const std::exception& e) {
std::cerr << e.what() << std::endl;
return EXIT_FAILURE;
}
}
game.ShutDown();
return EXIT_SUCCESS;
}