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(); realTime = Clock::now();
//simulate game time //simulate game time
while (simTime < realTime) { if (simTime < realTime) {
//call each user defined function while (simTime < realTime) {
activeScene->RunFrame(); //call each user defined function
//~60 FPS activeScene->RunFrame();
simTime += std::chrono::duration<int, std::milli>(16); //~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 //draw the game to the screen
+1 -1
View File
@@ -187,7 +187,7 @@ void ServerApplication::Proc() {
std::cerr << "Client dropped: " << disconnected << std::endl; std::cerr << "Client dropped: " << disconnected << std::endl;
} }
//give the computer a break //give the machine a break
SDL_Delay(10); SDL_Delay(10);
} }
delete reinterpret_cast<char*>(packetBuffer); delete reinterpret_cast<char*>(packetBuffer);