#### Archived

This topic is now archived and is closed to further replies.

# VB 5.0 Timer / Animation Problem...

## Recommended Posts

Zz    122
QUESTION: I am trying to insure my animation speed is the same on any computer I run my program on. Am trying to use a Timer control to do this but when I use a timer it is very slow. How can I keep my animation speeds constant on any computer? DISCUSSION: When I started writing my code I used a variable H to slow down my animation cycles of a large stone coming out the left side of the screen and reaching the center of the screen… While Z < 300 (300 was center) Screen.cls BitBlt ---- ,Z,--- screen.refresh For H = 1 to XXXX (XXXX was a number that I used to slow down in between cycles) Next H Next Z If the For H Loop was removed the animation would be near instantaneous of stone across screen. I knew that depending on your computer the XXXX would be to fast or to slow, so went to a timer control… Timer1_Timer() Z=Z+1 If Z <= 300 then Screen.cls BitBlt ---- ,Z,--- screen.refresh Else Timer1.Enabled = false End if End Sub I thought that this would allow me to control the speed by using the Timer1.Interval property but even when I set the Timer1.Interval = 1 it is very slow. Again, when I do not use Timer it is very fast. With the Timer it is to slow ?? I am only using Bitmaps although some are fairly large. Thanks for any help – Zz

  int frame;int timer;while(!done) //game main loop{timer++;if(timer%10==1)frame++;switch(frame)...if(frame>MAX_FRAME)frame=1;}