bugson
Mar 7th, 2000, 11:52 AM
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
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