Results 1 to 9 of 9

Thread: getting rid of timers...

  1. #1
    vshammas
    Guest

    Question getting rid of timers...

    hello all, i was wondering what alternative there was to using a timer to keep my tiles redrawing in an rpg im working on? when i use a timer it flickers all the time and is very annoying...is there a way to prevent it from flickering (this has to do with the timer right?) without using directx and backbuffers? thanks

  2. #2
    Fanatic Member
    Join Date
    Sep 1999
    Location
    Bethel, North Carolina, USA
    Posts
    987
    Use a DoEvents Loop

    VB Code:
    1. Private Sub Form_Load()
    2.  
    3. Me.Show
    4.  
    5. Do Until DoEvents = 0
    6.  
    7.   ' code in timer goes here
    8.  
    9. Loop
    10.  
    11. End Sub

    The code within the loop will run until the user closes the form.
    {Insert random techno-babble here}

    {Insert quote from some long gone mofo here}

  3. #3
    Zaei
    Guest
    Not cool. There is every posibility that you will want to do some kind of cleanup after your game loop. Use a global (probably the only place I endorse this) boolean. Then, in your initialization, if success, set the variable to true, and continue. Otherwise, set it to true:
    Code:
    'Initialization
    bRunning = True
    
    ...
    
    While bRunning
          
         ...
    
          DoEvents
    Wend
    
    'Cleanup
    Then, when you want to exit, just set this variable to False, and the next run of the loop will drop through, and exit.

    Z.

  4. #4
    Fanatic Member
    Join Date
    Sep 1999
    Location
    Bethel, North Carolina, USA
    Posts
    987
    Can't you do the same thing with a DoEvents Loop?

    VB Code:
    1. While DoEvents
    2.  
    3.    ' game body
    4.  
    5.  Wend
    6.  
    7.  ' clean up
    {Insert random techno-babble here}

    {Insert quote from some long gone mofo here}

  5. #5
    Frenzied Member Jotaf98's Avatar
    Join Date
    Jun 2000
    Location
    I'm not gonna give you my IP address! Ok... Portugal, South-Western Europe, 3rd rock from the sun (our star is easy to find, a 47 Ursae Majoris in the Milky Way :p )
    Posts
    1,457
    Hey here's the "FPS Slowdown" code I have always used:

    VB Code:
    1. 'Slow down the FPS...
    2.         Do Until GetTickCount() >= LastTick + TicksPerFrame
    3.             DoEvents
    4.         Loop
    5.         LastTick = GetTickCount()

    You'll have to declare TicksPerFrame and LastTick as Long, and declare GetTickCount() of course. You'll also have to make TicksPerFrame = the number of miliseconds each frame lasts (I have always used 30, it gives you a smooth animation without going too fast).

    Hope it helps
    Code:
    Temp = Me.GetIQ()
    'Error 9: Overflow
    'DON'T PANIC! :eek:

    To learn how to use realistic effects in your games like fire, rain, snow and magic effects, read my article on particles systems here.


    Jotaf's Theories!
    "Cats land on their feet. Toast lands peanut butter side down. A cat with toast strapped to its back will hover above the ground in a state of quantum indecision."

  6. #6
    vshammas
    Guest
    thanks everyone!

  7. #7
    Zaei
    Guest
    Using my code gives you a bit more control over where you exit the loop.

    Z.

  8. #8
    Fanatic Member PsychoMark's Avatar
    Join Date
    Feb 2001
    Location
    Netherlands
    Posts
    540

    Re: getting rid of timers...

    Originally posted by vshammas
    when i use a timer it flickers all the time and is very annoying...
    The flicker has nothing to do with the timer, a slow or jumping (don't know what else to call it) animation does. Using the loop will only speed things up (you should use a loop, yes), but the flicker probably won't go away... I think the problem is in your drawing code
    Teaudirenopossum.Musasapientumfixaestinaure.
    (I can't hear you. There's a banana in my ear)

  9. #9
    Zaei
    Guest
    To get rid of flicker, use AutoRedraw = True, or a back buffer.

    Z.

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