/*
This file is part of Minitrem.
Minitrem is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 2 of the License, or
(at your option) any later version.
Minitrem is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Minitrem. If not, see .
*/
#include "common.hpp"
#include
bool debug_draw_cmodels = false;
bool debug_draw_paths = false;
bool debug_draw_tile_coords = false;
bool debug_AI = false;
render::state_t *debug_render;
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);
size_t frame = 0;
double before = NAN;
game.interface = &interface;
debug_render = &render;
window.setVerticalSyncEnabled(true);
game::load_assets();
game.start();
while (1) {
double now = (nano_clock() - t0) * 1.0e-9, dt;
if (frame)
dt = now - before;
else
dt = 0.01;
game.tick(now, dt);
interface.tick(dt);
if (!window.isOpen())
break;
window.clear();
render.begin_frame(now, dt);
render.render(&game);
interface.render_to(&render);
render.end_frame();
before = now;
frame++;
}
game.stop();
return 0;
}