#include <vector>
#include <fov.h>
#include <iostream>
#include "util.h"
#include "game.h"
#include "renderer.h"

int main(int, char**)
{
  std::random_device randomEngine;
  std::mt19937 rng(randomEngine());

  try
  {
    Renderer renderer;
    Muxer muxer;

    Game game(rng, muxer);

    size_t lastTime = SDL_GetTicks();
    while (!game.quit)
    {
      size_t currentTime = SDL_GetTicks();
      size_t frameTime = currentTime - lastTime;
      lastTime = currentTime;

      game.update(frameTime);
      renderer.renderGame(game, true);
      muxer.update();
    }
  } catch (const sdl_error& ex)
  {
    std::cout << "SDL error (" << ex.what() << ")" << std::endl;
  } catch (const img_error& ex)
  {
    std::cout << "SDL_IMG error (" << ex.what() << ")" << std::endl;
  }

  return 0;
}