Removed delta time system from the framework

This commit is contained in:
Kayne Ruse
2014-08-19 02:52:15 +10:00
parent f52a022e64
commit 5dea53ad50
18 changed files with 31 additions and 31 deletions
+4 -4
View File
@@ -21,14 +21,14 @@
*/
#include "character.hpp"
void Character::Update(double delta) {
void Character::Update() {
if (motion.x && motion.y) {
origin += motion * delta * CHARACTER_WALKING_MOD;
origin += motion * CHARACTER_WALKING_MOD;
}
else if (motion != 0) {
origin += motion * delta;
origin += motion;
}
sprite.Update(delta);
sprite.Update(0.016);
}
void Character::DrawTo(SDL_Surface* const dest, int camX, int camY) {
+1 -1
View File
@@ -40,7 +40,7 @@ public:
Character() = default;
~Character() = default;
void Update(double delta);
void Update();
//graphics
void DrawTo(SDL_Surface* const, int camX, int camY);
+3 -3
View File
@@ -120,7 +120,6 @@ void ClientApplication::Proc() {
//prepare the time system
typedef std::chrono::steady_clock Clock;
std::chrono::duration<int, std::milli> delta(16);
Clock::time_point simTime = Clock::now();
Clock::time_point realTime;
@@ -138,8 +137,9 @@ void ClientApplication::Proc() {
//simulate game time
while (simTime < realTime) {
//call each user defined function
activeScene->RunFrame(double(delta.count()) / std::chrono::duration<int, std::milli>::period::den);
simTime += delta;
activeScene->RunFrame();
//~60 FPS
simTime += std::chrono::duration<int, std::milli>(16);
}
//draw the game to the screen
+2 -2
View File
@@ -75,10 +75,10 @@ SceneList BaseScene::GetNextScene() const {
//Frame loop
//-------------------------
void BaseScene::RunFrame(double delta) {
void BaseScene::RunFrame() {
FrameStart();
HandleEvents();
Update(delta);
Update();
FrameEnd();
}
+2 -2
View File
@@ -40,13 +40,13 @@ public:
SceneList GetNextScene() const;
//Frame loop
virtual void RunFrame(double delta);
virtual void RunFrame();
virtual void RenderFrame();
protected:
virtual void FrameStart() {}
virtual void HandleEvents();
virtual void Update(double delta) {}
virtual void Update() {}
virtual void FrameEnd() {}
virtual void Render(SDL_Surface* const screen) {}
+1 -1
View File
@@ -80,7 +80,7 @@ CleanUp::~CleanUp() {
//Frame loop
//-------------------------
void CleanUp::Update(double delta) {
void CleanUp::Update() {
if (std::chrono::steady_clock::now() - startTick > std::chrono::duration<int>(10)) {
SetNextScene(SceneList::MAINMENU);
}
+1 -1
View File
@@ -50,7 +50,7 @@ public:
protected:
//Frame loop
void Update(double delta);
void Update();
void Render(SDL_Surface* const);
//Event handlers
+5 -5
View File
@@ -92,17 +92,17 @@ void InWorld::FrameStart() {
//
}
void InWorld::Update(double delta) {
void InWorld::Update() {
//suck in and process all waiting packets
SerialPacket* packetBuffer = static_cast<SerialPacket*>(malloc(MAX_PACKET_SIZE));
SerialPacket* packetBuffer = reinterpret_cast<SerialPacket*>(new char[MAX_PACKET_SIZE]);
while(network.Receive(packetBuffer)) {
HandlePacket(packetBuffer);
}
free(static_cast<void*>(packetBuffer));
delete reinterpret_cast<char*>(packetBuffer);
//update the characters
for (auto& it : characterMap) {
it.second.Update(delta);
it.second.Update();
}
//check the map
@@ -129,7 +129,7 @@ void InWorld::Update(double delta) {
}
if ((localCharacter->GetOrigin() + localCharacter->GetBounds()).CheckOverlap(wallBounds)) {
localCharacter->SetOrigin(localCharacter->GetOrigin() - (localCharacter->GetMotion() * delta));
localCharacter->SetOrigin(localCharacter->GetOrigin() - (localCharacter->GetMotion()));
localCharacter->SetMotion({0,0});
localCharacter->CorrectSprite();
SendPlayerUpdate();
+1 -1
View File
@@ -59,7 +59,7 @@ public:
protected:
//Frame loop
void FrameStart();
void Update(double delta);
void Update();
void FrameEnd();
void RenderFrame();
void Render(SDL_Surface* const);
+3 -3
View File
@@ -82,13 +82,13 @@ void LobbyMenu::FrameStart() {
//
}
void LobbyMenu::Update(double delta) {
void LobbyMenu::Update() {
//suck in and process all waiting packets
SerialPacket* packetBuffer = static_cast<SerialPacket*>(malloc(MAX_PACKET_SIZE));
SerialPacket* packetBuffer = reinterpret_cast<SerialPacket*>(new char[MAX_PACKET_SIZE]);
while(network.Receive(packetBuffer)) {
HandlePacket(packetBuffer);
}
free(static_cast<void*>(packetBuffer));
delete reinterpret_cast<char*>(packetBuffer);
}
void LobbyMenu::FrameEnd() {
+1 -1
View File
@@ -47,7 +47,7 @@ public:
protected:
//Frame loop
void FrameStart();
void Update(double delta);
void Update();
void FrameEnd();
void Render(SDL_Surface* const);
+1 -1
View File
@@ -72,7 +72,7 @@ void MainMenu::FrameStart() {
//
}
void MainMenu::Update(double delta) {
void MainMenu::Update() {
//
}
+1 -1
View File
@@ -37,7 +37,7 @@ public:
protected:
//Frame loop
void FrameStart();
void Update(double delta);
void Update();
void FrameEnd();
void Render(SDL_Surface* const);
+1 -1
View File
@@ -59,7 +59,7 @@ void OptionsMenu::FrameStart() {
//
}
void OptionsMenu::Update(double delta) {
void OptionsMenu::Update() {
//
}
+1 -1
View File
@@ -38,7 +38,7 @@ public:
protected:
//Frame loop
void FrameStart();
void Update(double delta);
void Update();
void FrameEnd();
void Render(SDL_Surface* const);
+1 -1
View File
@@ -40,7 +40,7 @@ SplashScreen::~SplashScreen() {
//Frame loop
//-------------------------
void SplashScreen::Update(double delta) {
void SplashScreen::Update() {
if (std::chrono::steady_clock::now() - startTick > std::chrono::duration<int>(1)) {
SetNextScene(SceneList::MAINMENU);
}
+1 -1
View File
@@ -36,7 +36,7 @@ public:
protected:
//Frame loop
void Update(double delta);
void Update();
void Render(SDL_Surface* const);
//members
+1 -1
View File
@@ -25,7 +25,7 @@
#include <cmath>
//the speeds that the characters move
constexpr double CHARACTER_WALKING_SPEED = 140.0;
constexpr double CHARACTER_WALKING_SPEED = 2.24;
constexpr double CHARACTER_WALKING_MOD = 1.0/sqrt(2.0);
//the bounds for the character objects, mapped to the default sprites