The following code has one call to a Line() function; if the only row in the following cole with the Line() function is executed, the frame rate drops to a fluid 60hz frame rate per second (the code shows also the frame rate on screen). If that row with the Line() function is commented, the frame rate is not limited to 60hz (you can see clearly the ball rotating at more speed and, at least on my machine, frame rate is over 200 frames/second).
My question is why this behaviour? Can someone explain what does the Line() function and how can I control the frame rate? Next is the example code:
;setup graphics
Graphics 800, 600, 32, 2
SetBuffer BackBuffer()
;create ball image
o = CreateImage(25, 25)
Oval 0, 0, 25, 25
GrabImage o, 0, 0
MidHandle o
Ball1XPos# = 400.0
Ball1YPos# = 300.0
Ball1XPosNew# = 0.0
Ball1YPosNew# = 0.0
diameter# = 150
angle# = 0.0
Repeat
Cls
Ball1XPosNew = (diameter * Cos(angle)) + Ball1XPos
Ball1YPosNew = (diameter * Sin(angle)) + Ball1YPos
;here is the strange, the Line() function drops frame rate to 60hz
Line Ball1XPos, Ball1YPos - diameter, Ball1XPos, Ball1YPos + diameter
;draw ball
DrawImage o, Ball1XPosNew, Ball1YPosNew
;fps counter
If MilliSecs()-settime>1000
getfps=setfps : setfps=0 : settime=MilliSecs()
Else
setfps=setfps+1
EndIf
Text 0,0,"FPS="+getfps
VWait
Flip(False);
;increment angle
angle = angle + 0.5
If (angle > 359) Then
angle = 0;
End If
;esc = exit
Until KeyHit(1)
WaitKey()
End
Hoping someone can explain this. Thanks a lot.
|