Skip to main content
gamedev.net
🔒 Locked

Timers

Started by Indy Jul 3, 2000 at 12:41 PM 8 replies 300+ views
Original Post
Indy
Indy
Does Windows have a limitation to Timers? I seemed to be experiencing problems. I am currently in the middle of a project, it''s a shoot-em up. I am trying to use the timers to set-off the alien attacks. Basically something like this:- If(TimerA->Timer(200)==true)LaunchA=true; Now, the starnge thing is, this is OK for the first wave of aliens, but as soon as another wave appears(at the same time) the timing seems to go alittle wrong. Animation frames begin to skip, the aliens are not consistantly apart, rogue aliens which belong to another set of aliens appear on the end of the waves. Maybe it''s my method of programming and they way I''m calling them in. I tried the same thing using the ''for'' loop to create a kind of timer and that workd OK. However, the ''for'' loop will be inconsistant as different machines will take different amount of time to execute the ''for'' loop. So any help will be appreciated. Thanks Indy Indsoft
Indy
Dak Lozar
Dak Lozar
I''m not totally sure about this... but, I think that the total number of timers that you can create would be equal to the number of windows that your system can create. I looked in MSDN and have not found anything to back up my assumption.

I would preclude using the windows timer in place of your own timer. I have written a class that utilizes GetTickCount().
The tickcount is set at boot time and wraps around when the computer is running 49.7 contiuous days.



Dave "Dak Lozar" Loeser
Dave Dak Lozar Loeser
"Software Engineering is a race between the programmers, trying to make bigger and better fool-proof software, and the universe trying to make bigger fools. So far the Universe in winning."--anonymous
goir
goir
Indy >> I would strongly advise against using windows timers. It''s an incrediable way to loose performance
Indy
Indy
Goir,
What do you recommend to use instead?

Dak,
I think your assumption is right. I read up on the Timers in a Windows reference book, and it doesn''t give a max figure.

However, I think I''ve managed to get rid of the problem.

Thanks you guys...


Indy.

PS Goir - still give me your recommendation, I''m very interested.
Indy
Andrea
Andrea
"Kill the Timer" and use instead

DWORD timeGetTime(void);

The function returns the time elapsed in milliseconds from Windows start.
You can modify the resolution (I dont remember how) but the default resolution is good enough (1ms about).

NOTE: remember to link with Winmm.lib (WINdows MultiMedia)
IpSeDiXiT
goir
goir
timeGetTime function is great to use, and it''s true the resulution is 1 ms on win95/98 systems. On win NT and 2000 the resolution is about 5 ms and there are functions that can improve this to 1 ms. But you can''t get any better than 1 ms with that function.
TPH
TPH
You may want to check out Multimedia Timers (try the MSDN). They should allow you to use timers pretty much like SetTimer, but provide a finer resolution as suggested by goir.
goir
goir
Julio >> They are the same

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.