|
-
Jan 6th, 2002, 09:34 AM
#1
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
-
Jan 6th, 2002, 10:25 AM
#2
Fanatic Member
Use a DoEvents Loop
VB Code:
Private Sub Form_Load()
Me.Show
Do Until DoEvents = 0
' code in timer goes here
Loop
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}
-
Jan 6th, 2002, 11:03 AM
#3
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.
-
Jan 6th, 2002, 11:11 AM
#4
Fanatic Member
Can't you do the same thing with a DoEvents Loop?
VB Code:
While DoEvents
' game body
Wend
' clean up
{Insert random techno-babble here}
{Insert quote from some long gone mofo here}
-
Jan 6th, 2002, 02:49 PM
#5
Frenzied Member
Hey here's the "FPS Slowdown" code I have always used:
VB Code:
'Slow down the FPS...
Do Until GetTickCount() >= LastTick + TicksPerFrame
DoEvents
Loop
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
-
Jan 6th, 2002, 03:24 PM
#6
-
Jan 6th, 2002, 04:15 PM
#7
Using my code gives you a bit more control over where you exit the loop.
Z.
-
Jan 7th, 2002, 03:41 AM
#8
Fanatic Member
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)
-
Jan 7th, 2002, 07:38 AM
#9
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|