Skip to content

Commit

Permalink
Revert "Fix dt"
Browse files Browse the repository at this point in the history
This reverts commit c3ef298.
  • Loading branch information
christt105 committed Oct 25, 2019
1 parent 487c466 commit 5a3cd9a
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 2 deletions.
32 changes: 30 additions & 2 deletions WhispEngine/WhispEngine/Application.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ Application::Application()
hardware = new HardwareInfo();
file_system = new FileSystem();
random = new Random();

first_frame = true;
}

Application::~Application()
Expand Down Expand Up @@ -85,13 +87,34 @@ void Application::PrepareUpdate()
{
dt = 0.0f;
}
else if (first_frame)
{

dt = 1.0f / framerate_cap;
}
else
{
dt = frame_time.Read();
frame_time.Start();
double framerate = 1000.00 / perfect_frame_time.ReadMs();

dt = 1.0f / framerate;

if (dt > 1.0f / (float)framerate_cap + 0.02f)
{
dt = 1.0f / (float)framerate_cap + 0.02f;
}
}

perfect_frame_time.Start();

// Change frame cap/Pause Game ========================================
if (input->GetKey(SDL_SCANCODE_F10) == KEY_DOWN)
{
apply_cap_frames = !apply_cap_frames;
}
if (input->GetKey(SDL_SCANCODE_F11) == KEY_DOWN)
{
pause_game = !pause_game;
}
}


Expand Down Expand Up @@ -198,6 +221,11 @@ void Application::FinishUpdate()
LoadConfNow();
}

if (first_frame == true)
{
first_frame = false;
}

if (last_sec_frame_time.Read() >= 1000)
{
last_sec_frame_time.Start();
Expand Down
1 change: 1 addition & 0 deletions WhispEngine/WhispEngine/Application.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ class Application
std::string organization;
std::string version;

bool first_frame = true;
float dt = 0.0f;

Timer last_sec_frame_time;
Expand Down

0 comments on commit 5a3cd9a

Please sign in to comment.