;rck109d
Global fullScreenMode = 2 ;windowed
Global screenBitDepth = 32 ;bitdepth for window, overridden to desktop default in windowed mode
;--------Graphics Initialization------------
Graphics 1024,768, screenBitDepth, fullScreenMode
Global timer_draw = CreateTimer(120) ;delay draw call
Global timer_FPS = CreateTimer(1.0) ;delay to set HUD fps to current fps
Global framesTicked = 0 ;keeps track of frames over last second
Global FPS# = 0.0 ;Frames Per Second to display
Repeat
WaitEvent() ;save CPU, those timers will trigger execution when needed
;other code here, beneficially on other timers for good thread-like stuff
If TimerTicks(timer_FPS) > 0 Then
FPS = framesTicked
framesTicked = 0
ResetTimer timer_FPS
EndIf
If TimerTicks(timer_draw) > 0 Then
Cls ;dont CLS elsewhere,
;If Windows forces redraw,
;let the Last frame remain up as long as possible
;code here to draw things
DrawPlrHUD()
;code here to draw things
Flip(False) ;immediately draw to the screen
framesTicked = framesTicked + 1 ; take note of another frame drawn
ResetTimer timer_draw ;make timer_draw wait another 1/120th of a second before coming in here
EndIf
Until KeyHit(1) ;stop the program on ESC key
;;;;
;;;;
;;;;
;;;;
Function DrawPlrHUD()
Text 0,0,"Frames Per Second: " + FPS#
Text 0,20,"Escape ESC to exit"
End Function
|