|
-
Aug 4th, 2000, 10:19 PM
#1
Thread Starter
Good Ol' Platypus
I really hate the built-in VB timers. I'm doing some games in VB, and the timers really don't work that well. Even if I put in 20, it acts the same as if I had put in 50! (in the INTERVAL). So, does anybody know where I could get a high-resolution timer (one that reads EVERY second?)
All contents of the above post that aren't somebody elses are mine, not the property of some media corporation. 
(Just a heads-up)
-
Aug 4th, 2000, 10:27 PM
#2
Thread Starter
Good Ol' Platypus
While we're still on the topic of timers, I need to ask:
If I were to use this code, would it work for every 10 milliseconds?
(I am using this because of DDraw):
Code:
Sub BLAHBLAHBLAH()
Dim D as Integer
Dim OldD as Integer
Dim Started as Boolean
...
...
Do
If Started = True then
OldD = D
D = GetTickCount()
Do While D < (OldD + 1)
D = D + 10
If D > OldD Then
Exit Loop
Else
MoveAllUnits
End If
Loop
Else
Started = True
D = GetTickCount()
End If
BlitScreen
Loop
That would make up for any movement loss due to bad FPS, right? (I mean call to the MoveAllUnits subroutine). It would fire every 10 milliseconds, wouldn't it?
All contents of the above post that aren't somebody elses are mine, not the property of some media corporation. 
(Just a heads-up)
-
Aug 5th, 2000, 04:26 AM
#3
New Member
The timer would seem to act the same if u just put in 20 or 50 cos thats in miliseconds so you probably wouldnt notice the difference.
If u want a delay of a second just type in a 1000!
If practice makes perfect...
and nobody's perfect...
why the hell practice?
-
Aug 5th, 2000, 04:40 AM
#4
Timer controls are only accurate to about plus/minus 6ms (assuming no other processing is going on.
You think VB is a good chioce for writing games?
-
Aug 5th, 2000, 07:42 AM
#5
Monday Morning Lunatic
sastraxi, I've just emailed you a hi res timer...see what you think of it.
I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
-- Linus Torvalds
-
Aug 5th, 2000, 09:16 AM
#6
Frenzied Member
Hey parksie, can you send that thing over here to? I want a look at it. Thanks
-
Aug 5th, 2000, 09:43 AM
#7
Use GetTickCount for accuracy up to 1ms. Make a Form with 2 CommandButtons (cmdStart and cmdStop) and put the following code into your Form.
Code:
Private Declare Function GetTickCount Lib "kernel32" () As Long
Dim ContTime As Boolean
Sub TimerEx(Interval As Long)
Do While ContTime = True
Start = GetTickCount
Do While GetTickCount < Start + Interval
DoEvents
Loop
'<--Place code here-->
Print "Hello"
Loop
End Sub
Private Sub cmdStart_Click()
ContTime = True
TimerEx (1000)
End Sub
Private Sub cmdStop_Click()
ContTime = False
End Sub
-
Aug 5th, 2000, 11:10 AM
#8
Thread Starter
Good Ol' Platypus
Thanks, Parksie! The timer would be great...if I could use it. Thanks anyway, though! Actually, I might use it in other programs, but not in this one.
Does anybody know if that Do....Loop code I inserted as a reply works? Because that may be what I'm using for my RTS. Actually, I think I need to make a few changes to the code:
Code:
Sub BLAHBLAHBLAH()
Dim D As Integer
Dim OldD As Integer
Dim Started As Boolean
Dim UseD As Integer
...
...
Do
If Started = True then
OldD = D
D = GetTickCount()
UseD = OldD
If D + 10 < UseD + 1 Then
Do While D < (OldD + 1)
D = D + 10
If D > OldD Then
Exit Loop
Else
MoveAllUnits
End If
Loop
UseD = OldD
Else
UseD = UseD - (D - OldD)
End If
Else
Started = True
D = GetTickCount()
End If
BlitScreen
Loop
End Sub
All contents of the above post that aren't somebody elses are mine, not the property of some media corporation. 
(Just a heads-up)
-
Aug 5th, 2000, 11:13 AM
#9
Thread Starter
Good Ol' Platypus
Oh, and to answer WOSSNAME's post, Yes. I do think VB is powerful. And if you don't think it's powerful enough to do 3D, think about this.... I got a VB Runtime error in Unreal Tournament, so THAT is a good game made in VB!
All contents of the above post that aren't somebody elses are mine, not the property of some media corporation. 
(Just a heads-up)
-
Aug 5th, 2000, 02:08 PM
#10
Fanatic Member
Unreal made with VB: Unreal
I believe that there was a VB runtime error and all that, but I'm pretty sure that they would have made it in C++ and maybe added a VB DLL or something.
(PS: Great example that the thing made in VB had a runtime error )
-
Aug 5th, 2000, 05:39 PM
#11
Addicted Member
What happens if the timer event doesn't have time to finish before the interval is over?
Is the timer unabled untill it's free, or will it stack up events and do them after the timer is unabled?
Pentax
Wilhelm Tunemyr,
Swede in London
[email protected]
"Dort, wo man Bücher verbrennt, verbrennt man am Ende auch Menschen"
Heinrich Heine (1797-1856)
Pravda vítezi!
(Truth prevails!)
-
Aug 5th, 2000, 09:56 PM
#12
Hyperactive Member
Hi Guys,
Thanks for the timing function Megatron. Works great (in the cmdStart_Click it should read (1000) not (100 0)). However, can you explain what happens here:
-----------------------------------------
Start = GetTickCount
Do While GetTickCount < Start + Interval
DoEvents
Loop
-----------------------------------------
I'm a beginner and I don't get this code.
As always.....
Thanks
-
Aug 6th, 2000, 09:09 PM
#13
Thread Starter
Good Ol' Platypus
To Pentax: If you were talking to me, about the timer thing:
I don't think mine will work, because I forgot a DoEvents(duh!)!
Anyway, I'd like to know more about that Unreal Tournament thing. I'll try and recreate the error.
All contents of the above post that aren't somebody elses are mine, not the property of some media corporation. 
(Just a heads-up)
-
Aug 7th, 2000, 02:49 AM
#14
Monday Morning Lunatic
Tomexx - ? "1000 not 1000" ?
This is a known problem here, where numbers get split up...you probably noticed it with your post which now makes no sense .
I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
-- Linus Torvalds
-
Aug 7th, 2000, 06:52 AM
#15
You could also use the SSubTimer from http://www.vbaccelerator.com
-
Aug 7th, 2000, 07:03 AM
#16
Hyperactive Member
Hello Sastraxi,
I do understand you are hating built in timers.
Try this:
Copy this code into the declarations section of the project.
Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
Use
To delay the program for 1 second, use this code:
Call Sleep(1000)
Good luck,
Michelle.
-
Aug 7th, 2000, 09:19 AM
#17
Thread Starter
Good Ol' Platypus
Not on the topic, or anything, but how many posts to become a Lively Member?
All contents of the above post that aren't somebody elses are mine, not the property of some media corporation. 
(Just a heads-up)
-
Aug 7th, 2000, 09:27 AM
#18
Monday Morning Lunatic
Well, Pentax is a lively member on 102 posts...
I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
-- Linus Torvalds
-
Aug 9th, 2000, 09:34 AM
#19
Thread Starter
Good Ol' Platypus
It's not on the topic, but I just got my 79th post (this one) and now am a lively memeber!!!
All contents of the above post that aren't somebody elses are mine, not the property of some media corporation. 
(Just a heads-up)
-
Aug 9th, 2000, 09:39 AM
#20
Fanatic Member
To Time or not to Time.....
http://www.mvps.org/ccrp/controls/ccrpcontrols.htm
loads of cool replacement controls - check it out, they're free too
-
Aug 9th, 2000, 09:52 AM
#21
Tomexx:
Code:
'Start is setting an "Start time" for us
Start = GetTickCount
'This loop pauses execution until the given amount of seconds pass by. (Start + Interval is the amount of milliseconds to pause)
Do While GetTickCount < Start + Interval
'DoEvents lets the OS do othr tasks so our App does not freeze
DoEvents
Loop
Sastraxi, it's 64 posts for a Lively Member. See this page for a list of all the titles.
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
|