Skip to main content
gamedev.net
🔒 Locked

making timer..

Started by ff8 Jan 9, 2005 at 3:42 AM 5 replies 800+ views
Original Post
ff8
ff8
hello everyone ... i have a question about making a timer how can i do static timer (work in any computer) because i made one if i test it in my computer it works and if test it in another computers it gets slow or fast and how can i select any area from my project and save it in jpg file bye!
Staffan E
Staffan E
I assume you mean a timer function in C++, like for example timeGetTime() or QueryPerformanceCounter() in the Win32 API.

What do you mean by "it gets slow or fast"? That it constantly lags behind or speeds ahead, or that it returns irregular time values? You really should try to improve your language so that people can understand you better and offer you better help with your problems.

---
Staffan Einarsson
Hack my projects! Oh Yeah! Use an SVN client to check them out.BlockStacker
ff8
ff8
sorry for my bad english
ok, can you tell me how can i make a timer?
thank you for your answering
Staffan E
Staffan E
Well if all you want is a function which returns the current time when you call it you should look into timeGetTime()

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/multimed/htm/_win32_timegettime.asp

It returns the number of milliseconds elapsed since the system started.
You'll need to link with winmm.lib for it to work. Also you need to remember to add
timeBeginPeriod(1);

at the beginning of your program and
timeEndPeriod(1);

at the end for the precision to be one millisecond.

---
Staffan Einarsson
Hack my projects! Oh Yeah! Use an SVN client to check them out.BlockStacker
ff8
ff8
thank you again :)
and about the another question ?
can you answer me :P

[Edited by - ff8 on January 9, 2005 7:18:38 AM]
nife
nife
You should be able to figure it out yourself, but here you go:

time passed since last update (which could be last frame):
delta_time = current_time - last_time

to check if a second is passed since last fps check (to display fps):
if (current_time - fps_time >= 1000)
update fps counter and set fps to 0

when doing movement or something like that you would do this:
movement = movement_in_a_millisecond * delta_time

or, if you're clever, to make it easy for yourself (remember to make delta_time a float):
delta_time = (current_time - last_time) / 1000
movement = movement_in_a_second * delta_time
Killers don't end up in jailThey end up on a high-score!
Solias
Solias
For your second question you'll want to use: glReadPixels() and a jpeg library. A few of those links look promissing, or maybe someone here can recomend a good one for you.

Topic Locked

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

Sign in to reply to this topic.