Results 1 to 4 of 4

Thread: I have a timer problem.....

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Dec 2001
    Location
    Great White North, ey?
    Posts
    202

    I have a timer problem.....

    Hello, I have a problem with timing, I made an animation in DD and I don't want to use a timer control, but if I don't use a timer, and put my animation code in the main loop, the animation loops too fast! How can I fix this?

    Thanks

    BTW: The only reason I don't want to use timer control is because I heard that on win2k and XP the timing is different and therefore the program won't run propely, is this true?

    Thanks again.

  2. #2
    Good Ol' Platypus Sastraxi's Avatar
    Join Date
    Jan 2000
    Location
    Ontario, Canada
    Posts
    5,134
    Well the Timer control sucks anyway, try using GetTickCount API:
    VB Code:
    1. Dim D As Long
    2. Dim C As Long
    3. D = GetTickCount
    4. C = 1000 / 30 '(30 = FPS you'd like to achieve for your animation, updating)
    5. Do
    6.     DoEvents
    7.     If GetTickCount - D >= C Then
    8.         D = GetTickCount
    9.         UpdateAnimation
    10.     End If
    11.     DrawAnimation
    12. Loop
    That's a basic Do...DoEvents...Loop code block. Feel free to experiment with that!
    All contents of the above post that aren't somebody elses are mine, not the property of some media corporation.
    (Just a heads-up)

  3. #3
    Zaei
    Guest
    Before I begin, timers are bad. Dont use them for animations, etc.

    Anyway, yes, on 2k, and XP, the timing is different. You have greater accuracy(within 10ms, instead of, say, 30ms). Regardless, if you put 1000ms as the timer elapsed time, it will fire at ABOUT that time, give or take ~30ms, on Win9x, or ~10ms on 2k or XP. That is the difference. That said, dont use timers. They will make your life a living hell. Use a standard game loop(like the one Sas posted above), and you will be much happier.

    Z.

  4. #4

    Thread Starter
    Addicted Member
    Join Date
    Dec 2001
    Location
    Great White North, ey?
    Posts
    202

    YES!!!!

    It worked!!!! I LOVE YOU MAN! lol!

    Thanks a lot!!!

Posting Permissions

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



Click Here to Expand Forum to Full Width