Page 1 of 6 123 ... LastLast
Results 1 to 10 of 52

Thread: Gettickcount and the rest...

  1. #1

    Gettickcount and the rest...

    Looking into game loops rather than using timers. So, my question is:

    What is the best and most successful way of using a loop?

    I see there are loads of ways to get the time elapsed but which is best and what are the following:

    Gettickcount
    Timegettime
    QueryPerfomanceCounter
    QueryPerformancefrequency

    So...which is best for a game running at a maximum of say 100 Fps. I am using delphix, I need the game to run as smooth as possible on most machines possible. Obviously I have been on google and found loads of ways to achieve game loops, but with so many options, there must be a "best" way

    Thanks

  2. #2

    Gettickcount and the rest...

    TimeGetTime is probably the most accurate and reliable (queryperformance counter isnt reliable)

  3. #3

    Gettickcount and the rest...

    I've been using GetTickCount in Village Defense and sofar there haven't been any problems. That said, I really can't tell if the other are any better or worse.

  4. #4

    Gettickcount and the rest...

    I used the performance queries, but had no problems at all. No irregularities or inconsistencies.

  5. #5

    Gettickcount and the rest...

    Quote Originally Posted by tux
    TimeGetTime is probably the most accurate and reliable (queryperformance counter isnt reliable)
    What do you mean by "isnt reliable", personally I always used GetTickCount only lately I discovered QueryPerfomance. QueryPerfomance should give a much higher resolution timer..
    [size=9px]BEGIN GEEK CODE BLOCK
    <br />d s-- : a24 GB GCS GTW GE C++ P L+ W++ N+ K- w++++ M- PS+ PE+ Y- t+ 5+++ X+ R*
    <br />tv b+ DI++ D+ e++ h+ G-
    <br />END GEEK CODE BLOCK[/size]
    <br />Create your own GeekCode block at: <a href="">...</a>

  6. #6

    Gettickcount and the rest...

    well i read this and im at a loss now

  7. #7

    Gettickcount and the rest...

    Umm... not much i could add, 'cause i was fine with GetTickCount's precision till now, but here's another opinion about timers. He ended up using timeGetTime btw

  8. #8

    Gettickcount and the rest...

    I see even you experts are as confused as me perhaps

    I have now tested gettickcount and timegettime.

    Confirmed that timegettime is bar far the better.

    As some of you will have read, my computer seems to be ..well ****ed up somehow, timers are bonkers. Gettickcount, slowed down unbelievably with delphix..and was awful.
    Timegettime runs the game perfectly, with no slow down. It works like a dream.

    This is my loop procedure, it is probably awfully inefficient, so if there are any pointers you guys can add like "hey that isn't how it is supposed to be done" then tell me

    Code:
    Procedure TheGameLoop;
    begin
    
    While &#40;Finished=false&#41;do
    begin
    
    Application.processmessages;
    
    CurrentTime&#58;=timegettime-StartTime;
    
    If &#40;CurrentTime>TheInterval&#41;then
    begin
    
    StartTime&#58;=timegettime;
    
    if not mainfm.DXDraw1.CanDraw then Exit;
    
    -----the rest
    
    Application.processmessages;
    
    end;
    
    end;
    
    end;
    Interval is set when you use or don't use Vsync. If Vsync, Refreshrate=monitor refresh, Interval :=1000/Refreshrate. , if no vsync, I set to 1000/60.

  9. #9

    Gettickcount and the rest...

    Looks good to me.

    You could argue whether it is necessary to use application.processmessages twice in the loop, but I doubt it'll hurt.

  10. #10

    Gettickcount and the rest...

    I spoke too soon It seems there is some problem with some aspect of delphix, directx, my graphic card or Win XP.

    Timegettime is indeed running at 1000 ticks a sec. No matter what (as opposed to the timers that seem to run 64 fps regardless)

    However, when delphi is not open (or DXDIAG), the speed of the game slows down considerably just like the timers. Timegettime is certainly still running at 1000 a sec, but thr game is for some reason slowing down. Something is stopping it drawing to the screen perhaps.

    What ever it is, I expect that this will again be incorporated into the exe. I will test it tomorrow, and I will also be buying a new card soon.

    If none of these work, I may have to go back to Win2000, because something is really wrong here. Why the hell would it work proper if delphi is open as opposed to closed?

    :?:

Page 1 of 6 123 ... LastLast

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •