-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
36 lines (27 loc) · 710 Bytes
/
main.cpp
File metadata and controls
36 lines (27 loc) · 710 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
34
35
36
#include <chrono>
#include <iostream>
#include "Game.h"
int main()
{
constexpr unsigned int FPS = 60;
constexpr unsigned int frameDelay = 1000 / FPS;
Uint32 frameStart;
unsigned int frameTime;
auto start = std::chrono::high_resolution_clock::now();
Game game("Chess", 800, 800);
auto end = std::chrono::high_resolution_clock::now();
std::cout << "Time to load game: " << std::chrono::duration_cast<std::chrono::milliseconds>(end - start).count()
<< "\n";
while (game.isRunning())
{
frameStart = SDL_GetTicks();
game.handleEvents();
game.draw();
frameTime = SDL_GetTicks() - frameStart;
if (frameDelay > frameTime)
{
SDL_Delay(frameDelay - frameTime);
}
}
return 0;
}