Beginner C/C++

Moderators: None (Apply to moderate this forum)
Number of threads: 5430
Number of posts: 16951

This Forum Only
Post New Thread
Single Post View       Linear View       Threaded View      f

Report
Putting Time in C Posted by Oid21 on 7 Mar 2003 at 5:22 PM
I want to know how to put a timer like a game timer in my game made in c
please give me a concrete example...
Report
Re: Putting Time in C Posted by stober on 9 Mar 2003 at 8:14 AM
: I want to know how to put a timer like a game timer in my game made in c
: please give me a concrete example...
:

depends on the OS. If you are writing for MS-DOS 6.X, then you will have to hook into the clock interrupt vector and probably use assembly language. In Windows, create another thread and use Sleep() to create the affect of a timer. I suppose you would do something similar with unix.
Report
Re: Putting Time in C Posted by Wudu on 9 Mar 2003 at 12:37 PM
: : I want to know how to put a timer like a game timer in my game made in c
: : please give me a concrete example...
: :
:
: depends on the OS. If you are writing for MS-DOS 6.X, then you will have to hook into the clock interrupt vector and probably use assembly language. In Windows, create another thread and use Sleep() to create the affect of a timer. I suppose you would do something similar with unix.
:


In Windows it is not necessary to create another thread. It depends on the timerresolution to choose the method:
- GetTickCount() or time()
the resolution should be ms but it isnt ...
- QueryPerformanceCounter() uses some processorstuff ..
use that if you need a _high_ resolution timer

Report
Re: Putting Time in C Posted by stober on 9 Mar 2003 at 2:11 PM
You would need to create another thread only if you want a function to wake up at specific time intervals. And its the same with MS-dos -- you don't need the clock interrupts if all you want to do is get the current system time. So I guess it all depends on what the original poster meant by a game timer in my game



 

Recent Jobs

Official Programmer's Heaven Blogs
Web Hosting | Browser and Social Games | Gadgets

Popular resources on Programmersheaven.com
Assembly | Basic | C | C# | C++ | Delphi | Flash | Java | JavaScript | Pascal | Perl | PHP | Python | Ruby | Visual Basic
© Copyright 2011 Programmersheaven.com - All rights reserved.
Reproduction in whole or in part, in any form or medium without express written permission is prohibited.
Violators of this policy may be subject to legal action. Please read our Terms Of Use and Privacy Statement for more information.
Operated by CommunityHeaven, a BootstrapLabs company.