|
-
Jan 26th, 2002, 09:57 AM
#1
Thread Starter
Addicted Member
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
-
Jan 26th, 2002, 07:33 PM
#2
Lively Member
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...
-
Jan 28th, 2002, 10:08 AM
#3
Yeah, use the GetTickCount() API call.
Z.
-
Jan 28th, 2002, 10:13 AM
#4
Fanatic Member
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)
-
Jan 28th, 2002, 11:05 AM
#5
Thread Starter
Addicted Member
THanks...but
Hello, thank you for your help, but could you please tell me how I declare the TickCount API?
Thanks!
-
Jan 28th, 2002, 11:59 AM
#6
Thread Starter
Addicted Member
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
-
Jan 28th, 2002, 10:26 PM
#7
Junior Member
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|