Results 1 to 7 of 7

Thread: How to use Timer - TickCount in DX?

  1. #1

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

    How to use Timer - TickCount in DX?

    Hello, I'm wonder how to use the tickcount thing in DX, becasue timers are way to slow, I need it to calculate time between different actions, such as camera movements

    Thanks

  2. #2
    Lively Member
    Join Date
    Sep 2001
    Posts
    74

    hi

    Direct X shouldn't really make any difference in how you use get tick count. Timer controls are pretty accurate down to 10 milliseconds after that they degrade.

    Function GameLoop()
    Dim LastCount As Long
    Dim ThisCount As Long

    LastCount = GetTickCount
    Do
    ThisCount = GetTickCount
    If ThisCount - LastCount >= Interval Then
    'Timer Function
    End If
    ThisCount = GetTickCount
    If ThisCount - LastCount >= Interval2 Then
    'Timer Function
    End If
    DoEvents
    Loop
    End Function
    All will fall before the might of the Black Sashi...

  3. #3
    Zaei
    Guest
    Yeah, use the GetTickCount() API call.

    Z.

  4. #4
    Fanatic Member PsychoMark's Avatar
    Join Date
    Feb 2001
    Location
    Netherlands
    Posts
    540
    Doesn't DX8 have the DX.TickCount() function anymore? Does the same, eliminates the need to declare the function
    Teaudirenopossum.Musasapientumfixaestinaure.
    (I can't hear you. There's a banana in my ear)

  5. #5

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

    THanks...but

    Hello, thank you for your help, but could you please tell me how I declare the TickCount API?

    Thanks!

  6. #6

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

    Ok...

    I declared everything now, but this doesn't work

    Sub GameLoop()
    Dim LastCount As Long
    Dim ThisCount As Long

    LastCount = GetTickCount
    Do
    ThisCount = GetTickCount
    If ThisCount - LastCount >= 3500 Then

    MoveGuyForward

    End If
    ThisCount = GetTickCount
    If ThisCount - LastCount >= 2000 Then

    MoveGuyBackwords

    End If
    DoEvents
    Loop
    End Sub

    I want to move guy forward for 3.5 seconds,and after move backwords for 2 seconds, but nothing works, what's wrong, plz help!

    Thanks

    Thanks

  7. #7
    Junior Member Caleb's Avatar
    Join Date
    Jan 2001
    Posts
    24

    try this

    Code:
    Sub GameLoop() 
      Dim LastCount As Long 
      Dim ThisCount As Long 
    
      LastCount = GetTickCount 
      Do Until ThisCount - LastCount <= 3500
    
        MoveGuyForward 
    
        ThisCount = GetTickCount 
    
        DoEvents 
    
      Loop
    
      LastCount = GetTickCount 
      
      Do Until ThisCount - LastCount <= 2000
    
        MoveGuyBackwords 
    
        ThisCount = GetTickCount 
    
        DoEvents 
    
      Loop 
    End Sub
    Last edited by Caleb; Jan 28th, 2002 at 10:32 PM.

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