|
-
Dec 20th, 2001, 03:52 PM
#1
Timer control
I'm making animations using the Timer control and a Shape control. The animation consists only on moving the shape. The smaller the interval is, the slower the movement is and it shouldn't happen with the code I wrote. At least I think so. I calculate the object's x and y before starting, and so, the Timer just need to move the shape. Is that too much work to do in 10 miliseconds, to move?
I hope I don't need to learn Direct X or something like that because I believe I can put this simple. Is the Timer control the apropriate tool for this?
Thanks for any help.
-
Dec 20th, 2001, 03:59 PM
#2
Good Ol' Platypus
It doesn't have very good accuracy, Fox would tell you its the devil 
Here's a suitable replacement, using the GetTickCount API call:
VB Code:
Dim SaveCount As Long
SaveCount = GetTickCount
Do
If GetTickCount - SaveCount >= 10 Then
SaveCount = GetTickCount
Frame = Frame +1
DrawAnimation
End If
Loop
All contents of the above post that aren't somebody elses are mine, not the property of some media corporation. 
(Just a heads-up)
-
Dec 20th, 2001, 04:07 PM
#3
I already called it the devil for the hours I wasted trying to put the program working properly without results.
Thanks for the code, I'll try it.
-
Dec 20th, 2001, 04:20 PM
#4
LOL The movement was supposed to last 5 seconds and not 1 
Now it's too quick.
Precisely, how much time lasts a frame in that code?
-
Dec 20th, 2001, 04:28 PM
#5
GetTickcount counts the milliseconds since systemstart.
If GetTickCount - SaveCount >= 10 Then
So that would be true every 10 milliseconds ;-)
You're welcome to rate this post!
If your problem is solved, please use the Mark thread as resolved button
Wait, I'm too old to hurry!
-
Dec 20th, 2001, 05:05 PM
#6
Thank you both very much! This function is really something. Now I know what am I doing.
-
Dec 21st, 2001, 11:44 AM
#7
PowerPoster
It is evil indeed!! Arrgh!! *is attacked by a Timer* help me out here! Help! arrr....
Timer: *hrhr* People will always use Timers! *hrhr*
Fox: Nooo!!! *takes his sword of light* Diiieee!!!
[snip - censored]
Timer: Awww!!!! But I have family and..*arrrr!!!*
Fox: Haha! I finally won!
GetTickCount: Well done, Fox!
Fox: My pleasure, now it's time for us to rule the world!
Both: Hahahaha! *evil grin*
Thank you, thank you *bows*
-
Dec 25th, 2001, 05:30 PM
#8
Programming Newbie: But here I am! And I have brought a friend!
Mad Scientist: Yes, me! I will resurrect the Timer with my powerful tool "Bad Game Programming Tutorial".
*bright flash of light*
Timer: Muahaha, I'm alive again. Fox has won for now, but I'll gather strength and then RETURN! And then computer games are DOOOOOOOMED! MUAHAHAHAHAHA!!!!
*all off*
All the buzzt
 CornedBee
"Writing specifications is like writing a novel. Writing code is like writing poetry."
- Anonymous, published by Raymond Chen
Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.
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
|