Results 1 to 8 of 8

Thread: Timer control

  1. #1
    Moon
    Guest

    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.

  2. #2
    Good Ol' Platypus Sastraxi's Avatar
    Join Date
    Jan 2000
    Location
    Ontario, Canada
    Posts
    5,134
    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:
    1. Dim SaveCount As Long
    2. SaveCount = GetTickCount
    3. Do
    4.     If GetTickCount - SaveCount >= 10 Then
    5.         SaveCount = GetTickCount
    6.         Frame = Frame +1
    7.         DrawAnimation
    8.     End If
    9. 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)

  3. #3
    Moon
    Guest
    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.

  4. #4
    Moon
    Guest
    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?

  5. #5
    I don't do your homework! opus's Avatar
    Join Date
    Jun 2000
    Location
    Good Old Europe
    Posts
    3,863
    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!

  6. #6
    Moon
    Guest
    Thank you both very much! This function is really something. Now I know what am I doing.

  7. #7
    PowerPoster Fox's Avatar
    Join Date
    Jan 2000
    Location
    *afk*
    Posts
    2,088
    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*

  8. #8
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594
    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
  •  



Click Here to Expand Forum to Full Width