|
-
Dec 2nd, 2002, 12:06 PM
#1
Pls explain this procedure * solved
Im debugging my friend's program and I can't understand the use of this piece of code:
Code:
Public Sub FPS()
Do While mlngFrameTime + (1000 \ MAX_FPS) > gdx.TickCount
DoEvents
Loop
mlngFrameTime = gdx.TickCount
If mlngTimer + 1000 <= gdx.TickCount Then
mlngTimer = gdx.TickCount
mintFPS = mintFPSCounter + 1
mintFPSCounter = 0
Else
mintFPSCounter = mintFPSCounter + 1
End If
End Sub
mintFPS and mintFPSCounter are used only in this procedure . My first thought was a logical error, but I don't know what the procedure is for, hence, how it should have been coded.
FPS is used only in the FadeIn procedure (called) and in the main loop (DDraw.FPS). I think it's used to run DoEvents, since the main loop doesn't have one, but I can't figure out the purpose of the If statement. Neither could she, so she left it in the program after building up on a template she downloaded.
If you could give me a better code for whatever purpose this code was meant for, I'd really appreciate it.
Last edited by leinad31; Dec 2nd, 2002 at 03:07 PM.
-
Dec 2nd, 2002, 12:22 PM
#2
VB Code:
Public Sub FPS()
'The code is looping a while before gdx.tickCount is bigger then the rest...
Do While mlngFrameTime + (1000 \ MAX_FPS) > gdx.TickCount
'Just waits here...
DoEvents
Loop
'assigns a new "time" to the varaibale
mlngFrameTime = gdx.TickCount
'checks if there has been more then one seccond since last time.
If mlngTimer + 1000 <= gdx.TickCount Then
'assigns a new "time" to the varaibale
mlngTimer = gdx.TickCount
'increeses the variable by one more then mintFPSCounter
mintFPS = mintFPSCounter + 1
'sets the mintFPSCounter-variable to 0
mintFPSCounter = 0
Else
'increases the variable by one.
mintFPSCounter = mintFPSCounter + 1
End If
End Sub
I think your code is used to count Frames Per Second = FPS 
Ooooo****, by telling you that, I became an addictive member...****...
Last edited by NoteMe; Dec 2nd, 2002 at 12:47 PM.
-
Dec 2nd, 2002, 12:43 PM
#3
So if I were to output the FPS to the user then mintFPS would be of use.
Since mintFPS isn't found anywhere else in the project, I can remove the If statement?
As to the loop, what's the point of the comparison? Can't I just put DoEvents in the main loop? As I see it, I can either:
1) Call FPS from the main loop and the code 'just waits' to exit the Do While loop, or
2) I can run DoEvents, without the comparison, everytime the main loop cycles and do away with the procedure.
Which is the better way and why? Is there a reason to avoid DoEvents, hence, the If statement?
-
Dec 2nd, 2002, 12:48 PM
#4
If you don't want the app to show FPS, I suppose you can delete the whole SUB...
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
|