|
-
Mar 7th, 2000, 12:52 PM
#1
Thread Starter
New Member
Hi vb experts,
I'm trying to draw a moving ball in VB. I use bitblt and a for loop to change its position. The problem I have is that the ball is moving too fast (too fast that I couldn't even see it). So, I want some delay in between each bitblt call.
I couldn't use the "now" function since the smallest interval for "now" is 1 second.
So, I turn to using a timer. However, a time doesn't accept parameters, so I have difficulties passing the x,y coordinate to it.
Then, I thought of using a global flag variable, say DoDraw.
I set DoDraw = True inside the timer, and using something like the following in my drawing rountine.
for i = 0 to 100
while DoDraw = false
DoEvents
wend
DoDraw = false
bitblt ....
next i
However, I don't understand why eventhough I have set the interval of the timer to be 1, this piece of code still run very very slowly. Or should I say the ball moves very slow.
(a lot slower than 1 millisec in between.)
Can anyone show me a clever way of delaying less than a second?
Thank you so much
Happy programming
Bugson
-
Mar 7th, 2000, 08:25 PM
#2
New Member
well.. the timer would be the best way.
and you could do it with a little modification.
but there is a way i think would work for you in the for-next loop.
make it for i=0 to 100 step x
the step tells it to do it in increments of x. so make x a decimal number (say, .5) and it should slow it down some.
-
Mar 7th, 2000, 10:02 PM
#3
PowerPoster
Hi,
Please don't take a timer. PLEASE! I hate timers! Take GetTickCount from the API and make your own timer...
Put this anywhere in your loop:
Code:
Dim Temp As Long
Dim Delay as Long
Temp = GetTickCount
Delay = 10 'Ten milliseconds
While Temp + Delay > GetTickCount
DoEvents 'Optionally
Wend
(Thats a loop which waits for <Delay> milliseconds before it continues. It's the same like a timer, but IMO much better
-
Mar 8th, 2000, 03:47 AM
#4
Thread Starter
New Member
Thanks guys. I tried gettickcount and it is exactly what I want.
P.S fox, I hate timer too.
-
Apr 2nd, 2000, 10:54 AM
#5
PowerPoster

Doesn't anyone hear what I'm saying? *g*
-
Apr 2nd, 2000, 10:46 PM
#6
Frenzied Member
Hi Fox
I hear ya Fox Loud and clear.
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
|