12.07.2015 Views

Implementation of a Peer-to-Peer Multiplayer Game with ... - DVS

Implementation of a Peer-to-Peer Multiplayer Game with ... - DVS

Implementation of a Peer-to-Peer Multiplayer Game with ... - DVS

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

AIprintf("Init AI...\n");ctx ->ai->init(ctx ->game , ctx ->timer , ctx ->eventMgr);// init doneprintf("<strong>Game</strong> running.\n");}} else {printf("Connect failed!\n");delete ctx ->ai;delete ctx ->networkEngine;delete ctx ->eventMgr;delete ctx ->timer;delete ctx ->game;delete ctx ->device;delete ctx;}// node start function , called from SML simula<strong>to</strong>r codevoid startNode(const char* peerAddr , const char* gatewayAddr) {printf("Starting node (connect <strong>to</strong> \"%s\").\n", peerAddr);static bool first = true;// create context objectMainContext* ctx = new MainContext();// create objectsprintf("Setting up...\n");ctx ->eventMgr = new EventManager();ctx ->device = new IrrlichtDev(ctx ->eventMgr , first);ctx ->game = new Impl<strong>Game</strong>Instance ();ctx ->timer = new BSTimer();ctx ->networkEngine = new P2NetworkEngine (8585, peerAddr , gatewayAddr);ctx ->ai = new SimpleAI();// connect <strong>to</strong> networkprintf("Connecting <strong>to</strong> the network ...\n");ctx ->networkEngine ->init(ctx ->timer , ctx ->eventMgr , ctx ->game);ctx ->networkEngine ->configureUser(ctx ->device ->getDevice ());ctx ->networkEngine ->connectAsync(connectCallback , ctx);}first = false;88 A.1 Simulation: <strong>Game</strong> Main Code

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!