Reduced CPU load of the client

This commit is contained in:
Kayne Ruse
2015-01-13 01:34:59 +11:00
parent 74bf70c44d
commit de6eb38516
2 changed files with 12 additions and 6 deletions
+11 -5
View File
@@ -137,11 +137,17 @@ void ClientApplication::Proc() {
realTime = Clock::now();
//simulate game time
while (simTime < realTime) {
//call each user defined function
activeScene->RunFrame();
//~60 FPS
simTime += std::chrono::duration<int, std::milli>(16);
if (simTime < realTime) {
while (simTime < realTime) {
//call each user defined function
activeScene->RunFrame();
//~60 FPS
simTime += std::chrono::duration<int, std::milli>(16);
}
}
else {
//give the machine a break
SDL_Delay(10);
}
//draw the game to the screen
+1 -1
View File
@@ -187,7 +187,7 @@ void ServerApplication::Proc() {
std::cerr << "Client dropped: " << disconnected << std::endl;
}
//give the computer a break
//give the machine a break
SDL_Delay(10);
}
delete reinterpret_cast<char*>(packetBuffer);