KlassischeKeplerKriege/game/main.cpp
2016-09-28 07:28:18 +02:00

81 lines
1.7 KiB
C++
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#define ASIO_STANDALONE
#include <iostream>
#include <getopt.h>
#include <asio.hpp>
#include <cstdlib>
#include "opengl.hpp"
#include "game_window.hpp"
#include "server.hpp"
#include "options.hpp"
uint64_t optionsFlags;
using asio::ip::tcp;
using namespace std;
int main(int argc, char *argv[]) {
char port[]="3490";
char c;
static struct option long_options[] =
{
/* These options set a flag. */
// {"verbose", no_argument, &verbose_flag, 1},
// {"brief", no_argument, &verbose_flag, 0},
/* These options dont set a flag.
We distinguish them by their indices. */
// {"add", no_argument, 0, 'a'},
// {"append", no_argument, 0, 'b'},
// {"delete", required_argument, 0, 'd'},
{"port", required_argument, 0, 'p'},
{"fps", no_argument, 0, 'f'},
{0, 0, 0, 0}
};
int option_index = 0;
while(1){
c = getopt_long (argc, argv, "p:f",
long_options, &option_index);
if (c == -1)
break;
switch (c)
{
case 'f':
SET_FLAG(SHOW_FPS,true);
break;
case 'p':
strcpy(port,optarg);
break;
case '?':
/* getopt_long already printed an error message. */
break;
default:
abort();
}
}
Game game;
asio::io_service io_service;
Server s(io_service, game.state(), atoi(port) );
GameWindow window(500, 500, &game);
window.set_maxfps(60.0);
while(window.running()){
window.poll();
io_service.poll();
}
return 0;
}