//
// game.cpp
// 

// System includes.
#include <unistd.h>

// Engine includes.
#include "GameManager.h"
#include "LogManager.h"

// Game includes.
#include "FileName.h"
#include "functions.h"

int main(int argc, char *argv[]) {

  /////////////////////////////////////////////////
  // Parse command line args.
  int c;
  while ((c = getopt(argc, argv, "h")) != EOF) {
    switch (c) {

    case 'h':
      usage();
      break;

    default:
      printf("WARNING: invalid option - '%c'\n", c);
      usage();
      break;
    }
  }

  if (argc > 2)
    usage();

  /////////////////////////////////////////////////
  // Start up game manager.
  if (GM.startUp())  {
    LM.writeLog("Error starting game manager!");
    GM.shutDown();
    return 1;
  }

  LM.setLogLevel(1);

  // Get initial sprite filename.
  std::string filename;
  if (argc == 2)
    new FileName(argv[1]);
  else
    new FileName("");

  // Run until player exits.
  GM.run();

  // Shut everything down.
  GM.shutDown();

  return 0;
}
