main.cpp

Go to the documentation of this file.
00001 /*
00002  * main.cpp
00003  *
00004  *  Created on: Nov 20, 2011
00005  *      Author: sushil
00006  */
00007 
00008 #include <boost/thread.hpp>
00009 #include <boost/date_time.hpp>
00010 
00011 #include <getopt.h>
00012 #include <stdlib.h>
00013 #include <iostream>
00014 
00015 #include <engine.h>
00016 #include <entityMgr.h>
00017 
00018 #include <options.h>
00019 
00020 
00021 using namespace FastEcslent;
00022 
00023 //extern void gfxManager();
00024 
00025 Options makeOptions(int argc, char*argv[]){
00026         Options options;
00027         options.enableNetworking = true;
00028         options.networkPort      = 54321;
00029 
00030         //client
00031         options.isServer         = false;
00032         options.gameNumber = 1;
00033         options.side = BLUE;
00034         options.player = THREE;
00035 
00036 
00037         options.runAsEvaluator = true;
00038         options.instanceId = random();
00039 
00040         options.tacticalAI = true;
00041 
00042         options.enableGfx = true;
00043 
00044         options.runDebugTests = false;
00045 
00046         options.speedup = 10.0;
00047 
00048 
00049         return options;
00050 }
00051 
00052 int main(int argc, char *argv[]){
00053         srandom(time(NULL));
00054         Options options = makeOptions(argc, argv);
00055 
00056         Engine *engine = new Engine(random(), options);
00057 
00058         //Construct all the managers
00059         engine->constructManagers();
00060         //Initialize all the managers
00061         engine->init();
00062         //Launch game (1. gameMgr load game; 2. Run network)
00063         engine->loadLevel();
00064         //Run game
00065         engine->run();
00066         //Unload game
00067         engine->releaseLevel();
00068         //Stop game
00069         engine->stop();
00070 
00071         delete engine;
00072 
00073         return 0;
00074 }
00075 
00076 
00077 /*
00078         NetThread *net;
00079         if(options.enableNetworking){
00080                 net = new NetThread(engine);
00081                 net->init();
00082                 net->start();
00083         }
00084 
00085         GfxThread *gfx;
00086         if(options.enableGfx){
00087                 gfx = new GfxThread(engine);
00088                 gfx->init();
00089                 gfx->start();
00090         }
00091         sleep(2.0); //wait for graphics thread to get going, start gets the thread running
00092 
00093 
00094 
00095         while (!engine->quit) {
00096                 engine->loadLevel();
00097                 engine->run();
00098         }
00099 
00100         if (options.enableNetworking){
00101                 net->join();
00102         }
00103 
00104         if (options.enableGfx) {
00105                 //gfx->stop();
00106                 gfx->join();
00107 
00108         }
00109 
00110 */
00111 

Generated on Fri Dec 13 14:54:18 2013 for FastECSLent by  doxygen 1.5.4