#include "periodic_updates.hpp" #include #include static Ball* _ball = nullptr; static clock_t _last_time = 0; double time_of_clocks(clock_t time) { return ((double)time) / ((double)CLOCKS_PER_SEC); } void init_periodic_static(Ball* ball) { _last_time = clock(); _ball = ball; } void periodic_update() { clock_t now = clock(); _ball->update_pos(time_of_clocks(now - _last_time)); _last_time = now; glutPostRedisplay(); }