I'm trying to make a class that will help me calculating the delta time in my game.
dt.h:
dt.cpp:Code:#include <ctime> class dt { public: void SetMaxFPS(int num); void UpdateCurrentTicks(); void UpdateLastTicks(); long GetDeltaTime(); int GetFPS(); int GetMaxFPS(); bool UpdateNeeded(); private: long GetTicks(); int max_fps; int current_ticks; int last_ticks; };
main.cpp:Code:#include "dt.h" void dt::SetMaxFPS(int i) { max_fps = i; } void dt::UpdateCurrentTicks() { current_ticks = GetTicks(); } void dt::UpdateLastTicks() { last_ticks = current_ticks; } long dt::GetTicks() { return clock(); } long dt::GetDeltaTime() { return current_ticks - last_ticks; } int dt::GetFPS() { return (current_ticks - last_ticks) * 1000; } int dt::GetMaxFPS() { return max_fps; } bool dt::UpdateNeeded() { if(current_ticks > last_ticks + max_fps/1000) return true; return false; }
Code:#include "dt.h" int main(int argc, char* argv[]) { dt::SetMaxFPS(100); }
And I get the next error:
Code:error C2352: 'dt::SetMaxFPS' : illegal call of non-static member function
What am I doing wrong?




Reply With Quote