diff options
author | Paweł Redman <pawel.redman@gmail.com> | 2017-10-12 13:20:06 +0200 |
---|---|---|
committer | Paweł Redman <pawel.redman@gmail.com> | 2017-10-14 12:42:09 +0200 |
commit | e1da92454d096c28292699f64d891a3af292a204 (patch) | |
tree | db84ed861a55e6c4f61c7090c19d6f0e41b6cec5 /src/main.cpp | |
parent | 753f71536339b78c49468ba6452c96d6b3c345b2 (diff) |
Initial work on animations.
Diffstat (limited to 'src/main.cpp')
-rw-r--r-- | src/main.cpp | 21 |
1 files changed, 18 insertions, 3 deletions
diff --git a/src/main.cpp b/src/main.cpp index b63b610..e9a3301 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1,8 +1,19 @@ #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); @@ -11,15 +22,19 @@ int main() game.start(); while (1) { + double now = (nano_clock() - t0) * 1.0e-9; + game.tick(); interface.tick(); if (!window.isOpen()) break; - + window.clear(); - game.render(&window); + render.begin_frame(now); + render.render(&game); + //game.render(&render); interface.render(); - window.display(); + render.end_frame(); } return 0; |