|
|
| timers |
|
Money
Member #6,730
December 2005
|
can somone point me to a tutorial on timers..and how to use them? thanks |
|
CGamesPlay
Member #2,559
July 2002
|
Have a look at Loomsoft's tutorial. There are others at the site root. -- Ryan Patterson - <http://cgamesplay.com/> |
|
Money
Member #6,730
December 2005
|
thanks |
|
Tobias Dammers
Member #2,604
August 2002
|
And just so you know: For smooth animation, you're probably better off not using allegro timers; the best method is QueryPerformanceCounter for windows and gettimeofday for linux. Google should give you enough information about how to use them. Both work similarly and can be wrapped into a uniform timer api which is as simple as it can be. Strong points of both: --- |
|
Evert
Member #794
November 2000
|
Quote: gettimeofday for linux Actually, man gettimeofday said:
CONFORMING TO That basically means that it's portable to any UNIX system, including MacOS X (so basically, everything except Windows). Hmm... it might even be portable to MinGW, which makes it sortof portable to Windows too. |
|
HoHo
Member #4,534
April 2004
|
Quote: Hmm... it might even be portable to MinGW, which makes it sortof portable to Windows too. A quick google search makes me think migw doesn't support it [edit] Perhaps I was too hasty. Here is a way to give mingw gettimeofday function. Of cource it involves creating custom mingw build so if it is not in official mingw distribution by now* it is of little use *)The original "fix" was pruposed around mid-2001 and in late 2004 it wasn't in official release. I doubt it is there today, __________ |
|
Jakub Wasilewski
Member #3,653
June 2003
|
Quote: while allegro timers have a ~10 ms granularity on windows This can be easily remedied by using timeBeginPeriod and timeEndPeriod from the WinMM, probably coupled with some querying with timeGetDevCaps to see what is the minimal granularity possible (it'll likely be 10ms under Win98, but newer systems tend to support at least 1ms). Setting 1ms scheduler granularity will probably allow Allegro timers (they're implemented as threads, right?) to run more accurately, up to 1000 BPS. I use the more complicated delta time method myself, and it's better in many ways than what I described above, but the timer approach has the advantage of being very simple, and with beefed up granularity it's even quite smooth. --------------------------- |
|
Evert
Member #794
November 2000
|
Quote: Setting 1ms scheduler granularity will probably allow Allegro timers (they're implemented as threads, right?) to run more accurately, up to 1000 BPS.
It may and it may not. |
|
Murat AYIK
Member #6,514
October 2005
|
Can someone clarify this? I mean what would the error graph would look like on for example my 200 bps timer? Does it ever do "5-10-9-14-19" or "5-10-10-20" ? If we know what goes wrong then it would be easier to counter it, right? Just "knowing that it is bad" doesn't help much! _____________________________________________________ |
|
Sirocco
Member #88
April 2000
|
Quote: And just so you know: For smooth animation, you're probably better off not using allegro timers; the best method is QueryPerformanceCounter for windows and gettimeofday for linux. While I agree with that for complex 3D scenes, the vast majority of 2D games (and simple 3D ones, I imagine) can be handled in a smooth and reliable fashion with a few well crafted timers. I've never had a reason to use a timer of greater frequency than 140 BPS, and even that could have been pared down to 70 if I had felt a little more inspired. Certainly for 3D games I'd go for delta time, but all my games run nicely using Allegro timers. --> |
|
Frank Drebin
Member #2,987
December 2002
|
Quote: For smooth animation, you're probably better off not using allegro timers
i don't believe so. |
|
scriptX
Member #6,574
November 2005
|
Quote: the best method is QueryPerformanceCounter for windows Just curious, how would you use that? |
|
ImLeftFooted
Member #3,935
October 2003
|
Heres how i do it:
GetTickCount is easier if all you need is millisecond precision. Where you need more accurate timers (in a typical game project) is with FPS counters. |
|
|