Hello, I working on a game in SDL. I want to reset the timer in every 15 seconds or so. I have tried SDL_GetTicks() but it works fine for first time after that time goes in -tive.
Thank-you
Printable View
Hello, I working on a game in SDL. I want to reset the timer in every 15 seconds or so. I have tried SDL_GetTicks() but it works fine for first time after that time goes in -tive.
Thank-you
SDL_GetTicks - SDL Documentation Wiki
How can it be negative when it returns an unsigned number?
Rather than trying to reset the system tick count (which you're not likely to be able to do, or if you can, there will be consequences), write your own simple wrapper class.
Something like
Code:class myclock {
private:
Uint32 base;
public:
myclock() { base = SDL_GetTicks(); }
reset() { base = SDL_GetTicks(); }
UInt32 elapsed() { return SDL_GetTicks() - base; }
};