void FullStateSenderPlayerV5::sendFullState() { static const char * playmode_string[] = PLAYMODE_STRINGS; // send begining of FS serializer().serializeFSBegin( transport(), stadium().time() ); if ( stadium().playmode() == PM_FreeKick_Left && stadium().ballCatcher() ) { serializer().serializeFSPlayMode( transport(), "goalie_catch_ball_l" ); } else if ( stadium().playmode() == PM_FreeKick_Right && stadium().ballCatcher() ) { serializer().serializeFSPlayMode( transport(), "goalie_catch_ball_r" ); } else { serializer().serializeFSPlayMode( transport(), playmode_string[stadium().playmode()] ); } serializer().serializeFSViewMode( transport(), ( self().highQuality() ? "high" : "low" ), ( self().viewWidth() == rcss::pcom::NARROW ? "narrow" : self().viewWidth() == rcss::pcom::WIDE ? "wide" : "normal" ) ); sendSelf(); sendScore(); sendBall(); const Stadium::PlayerCont::const_iterator end = stadium().players().end(); for ( Stadium::PlayerCont::const_iterator p = stadium().players().begin(); p != end; ++p ) { if ( ! (*p)->isEnabled() ) continue; sendPlayer( *(*p) ); } // send end of FS serializer().serializeFSEnd( transport() ); transport() << std::ends << std::flush; }
void multiPlayer() { int myMove; int oppMove = 0; int connect = 0; // Find other players while(!connect) { connect = findPlayer(); } // NOTE: Need to build something to determine who goes first // Compare Xbee ID's perhaps? // Begin game while(!game.gameOver && connect) { if(game.turn) { // Pick Move myMove = pickMove(); // Send Move sendMove(myMove); // Receive new score after opponent takes damage game.oppScore = recieveScore(); } else { // Receive player move and take damage game.myScore = attack(recieveMove(), game.myScore); // Send new score sendScore(game.myScore); } // Check game status game.gameOver = gameStatus(); !game.turn; } if (!connect) { printBSOD(); } else { printResults(); } }
void Environment::run(){ ((Fly*) entityMap.value(flyID))->move(); bool badAngle = false; if(!waitStart){ int tmpT = chrono.elapsed(); envTime currentTime = convertTime(tmpT); emit sendTime(currentTime); } if(getFly()->isInSlidingMod()){ getFly()->Boost(true); emit padBlock(); } if(getFly()->get_trigger().intersection(hitBox,sf::Color::Black)){ isSliding= false; if(!getFly()->isInSlidingMod()){ getFly()->Boost(false); } if(!badAngle && !isSliding){ badAngle = getFly()->slide(hitBox); isSliding = true; } if (badAngle) emit sigWall(); } if(((Fly*) entityMap.value(flyID))->get_trigger().intersection(hitBox,sf::Color::Red)){ // La Mort ! reloadLevel(); playerStat.insert("mort",playerStat.value("mort")+1); // bonusPurge(); // bonusLoader(level); } if(((Fly*) entityMap.value(flyID))->get_trigger().intersection(hitBox,sf::Color(0,255,0))){ if(((Fly*) entityMap.value(flyID))->get_trigger().intersection(hitBox,sf::Color(0,0,255)) && !isArrived){ emit sigWall(); getFly()->Boost(false); }else{ isArrived = true; } } if(((Fly*) entityMap.value(flyID))->get_trigger().isInSprite(hitBox,sf::Color(0,0,255)) && !waitStart && isArrived){ // ligne d'arrivee ! waitStart = true; isArrived = false; totalTime = chrono.elapsed(); if(totalTime < dataLoader.getBestTime()){ dataLoader.saveHighScore(QString("Data/level") + QString::number(level) + QString(".data"),timeToString(convertTime(totalTime))); emit sendTotalTime(convertTime(totalTime)); dataLoader.setBestTime(totalTime); } } if(((Fly*) entityMap.value(flyID))->get_trigger().isInSprite(hitBox,sf::Color::White) && waitStart){ // départ ! chrono.start(); waitStart = false; } // bpoint pt; // pt.first = entityMap.value(flyID)->get_x(); // pt.second = entityMap.value(flyID)->get_y(); // for(int i = 0; i < cacaIdList.size();i++){ // if(entityMap.value(cacaIdList[i])->get_trigger().isIN(pt.first,pt.second)){ // DM.remove(cacaIdList[i],pt.second); // /* if(entityMap.value(bonusIdList[i])->get_nom() == "caca") // playerStat.insert("score",playerStat.value("score")+100); // if(entityMap.value(bonusIdList[i])->get_nom() == "cacador") // playerStat.insert("score",playerStat.value("score")+1000); //*/ // entityMap.remove(cacaIdList[i]); // cacaIdList.remove(i); // cacaIdList.squeeze(); // } // } // for(int i = 0; i < cacadorIdList.size();i++){ // if(entityMap.value(cacadorIdList[i])->get_trigger().isIN(pt.first,pt.second)){ // DM.remove(cacadorIdList[i],pt.second); // /* if(entityMap.value(bonusIdList[i])->get_nom() == "caca") // playerStat.insert("score",playerStat.value("score")+100); // if(entityMap.value(bonusIdList[i])->get_nom() == "cacador") // playerStat.insert("score",playerStat.value("score")+1000); //*/ // entityMap.remove(cacadorIdList[i]); // cacadorIdList.remove(i); // cacadorIdList.squeeze(); // } // } DM.setEM(entityMap); emit sendDM(DM); emit sendMort(playerStat.value("mort")); emit sendScore(playerStat.value("score")); }