Putting Time in C

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...

Comments

  • : 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...
    :

    [blue]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.
  • : : 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...
    : :
    :
    : [blue]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.
    :

    [blue]
    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
    [/blue]
  • [blue]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[/blue] [red]a game timer in my game[/red]
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

In this Discussion