[SDL] Making 200Hz timer for Physics simulation code

mrl at netbank.com.br mrl at netbank.com.br
Thu Jan 17 13:35:03 PST 2002


On Thu, Jan 17, 2002 at 09:42:08PM +0200, Timo K Suoranta wrote:
> Can anyone suggest me how to make a timer which runs at 200Hz my simple
> physics simulation code?
> 
> Don't tell me to lower the frequency, I'm only interested in replies which
> actually let me know how to do it.
> 
> Will SDL Timer with interval of 5 ms do? Which platforms can/can not do
> this?
---end quoted text---

I don't know it's precision, but you should try calling gettimeofday() in a loop and only execute the code when 5ms passed..
But note that this will take 99% of your processor, since you cannot add any sleep here.. (none FWIK have this precision..) so I guess you can lower the priority without any problem if you are not really going to use the 99%..
-- 
Marcelo R Leitner <mrl at netbank.com.br>
ICQ #: 29966851




More information about the SDL mailing list