#define CG_PLAYERS 001
#define CM_PLAYERS 011
#define CAMERA_STEP 1500
-#define STEPS 1000
+#define STEPS 500
//-------------------------------------------------------------------------------------
Game::Game(string server, int port, string nickname, int delay)
newScoreUpdate = false;
animation = 0;
otherPlayer = 0;
+ gettimeofday(&gameStart, NULL);
+ struct timeval gameDuration;
+ gameDuration.tv_sec = 420;
+ gameDuration.tv_usec = 0;
+ timeradd(&gameStart, &gameDuration, &gameEnd);
+
if (gameServer != "offline")
moveCats(evt);
printStepsLeft();
printPlayerScore();
+ printTime();
gettimeofday(&curTime, NULL);
Real t = curTime.tv_sec - msgTime.tv_sec;
stepsBoard->showOnTop();
stepsBoard->setFontName("BlueHighway-12");
stepsBoardNode->attachObject(stepsBoard);
+
+ SceneNode* timeBoardNode = cameraNode->createChildSceneNode(Vector3( 5, 21.4, -8.5));
+ timeBoard = new MovableText("timeBoard", " . " );
+ timeBoard->setTextAlignment(MovableText::H_LEFT, MovableText::V_ABOVE);
+ timeBoard->setColor(ColourValue::Black);
+ timeBoard->setCharacterHeight(0.8);
+ timeBoard->showOnTop();
+ timeBoard->setFontName("BlueHighway-12");
+ timeBoardNode->attachObject(timeBoard);
+
if (nickName.length() > 0)
playerCaption = nickName;
void Game::exit()
{
+ gettimeofday(&gameEnd, NULL);
+ struct timeval gameDuration;
+
+ timersub(&gameEnd, &gameStart, &gameDuration);
+
+
memset(sendbuffer, 0, BUFFERSIZE);
int size = sizeof(struct timeval) + sizeof(Vector3) + sizeof(Quaternion) + sizeof(int);
client->sendMessage(sendbuffer, size);
cout << "------------------- SCORE ----------------------\n";
cerr << "printing score\n";
-
- const std::string filename = "results/" +
+
+ const std::string filename = "results/" + nickName + "/" +
StringConverter::toString(delay_ms) + "-" +
StringConverter::toString(sessionId) + "-" +
StringConverter::toString(myPlayerId) + ".txt";
+
+ const std::string testfilename = "test.txt";
ofstream file;
+
file.open(filename.c_str(), ios::out|ios::app|ios::binary);
file << score.size() << "\n";
- for (i = 0; i < score.size(); i++)
+ /* for (i = 0; i < score.size(); i++)
{
scoreunit current = score.at(i);
file << current.timestamp.tv_sec << " " <<
cout << "from player " << current.playerA << " to " << current.playerB << "\n";
- }
+ }*/
+
+ file << "punch(done:ack:rec) " << localPlayer->PunchesDone << " " << localPlayer->PunchesDoneAck << " " << localPlayer->PunchesReceived << "\n";
+ file << "handshake " << " " << localPlayer->HandshakesDone << " " << localPlayer->HandshakesDoneAck << "\n";
+ file << "RPS " << localPlayer->RPSDone << " " << localPlayer->RPSDoneAck << " " << localPlayer->RPSReceived << "\n";
+ file << "wave " << localPlayer->WavesDone << localPlayer->WavesDoneAck << " " << localPlayer->WavesReceived <<"\n";
+ file << "game(duration(sec)) " << gameDuration.tv_sec << "\n";
+
file.close();
cout << localPlayer->HandshakesDone << " handshakes done\n";
}
newScoreUpdate = false;
}
+void Game::printTime()
+{
+ std::string caption = "Time left (sec): ";
+ struct timeval now;
+ struct timeval timeLeft;
+ gettimeofday(&now, NULL);
+
+ timersub(&gameEnd, &now, &timeLeft);
+ caption = caption + StringConverter::toString(timeLeft.tv_sec);
+
+ timeBoard->setCaption(caption);
+ if (timeLeft.tv_sec <= 0)
+ exit();
+}
#if OGRE_PLATFORM == OGRE_PLATFORM_WIN32