blob: 82b5e2e4e941cc573f3cc58afdc442a2d374229f (
plain)
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
37
38
39
40
41
42
|
#include "common.hpp"
#include <ctime>
uint64_t nano_clock(void)
{
struct timespec ts;
clock_gettime(CLOCK_MONOTONIC_RAW, &ts);
return ts.tv_sec * 1000000000LLU + ts.tv_nsec;
}
int main()
{
uint64_t t0 = nano_clock();
sf::RenderWindow window(sf::VideoMode(800, 600), "Minitrem");
render::state_t render(&window);
game::state_t game;
interface::state_t interface(&window, &game);
window.setVerticalSyncEnabled(true);
assets::load();
game.start();
while (1) {
double now = (nano_clock() - t0) * 1.0e-9;
game.tick();
interface.tick();
if (!window.isOpen())
break;
window.clear();
render.begin_frame(now);
render.render(&game);
interface.render();
render.end_frame();
}
return 0;
}
|