Back to index

freevial  1.2
Public Member Functions | Public Attributes | Static Public Attributes
common.freevialglob.frameRate Class Reference

List of all members.

Public Member Functions

def __init__
def segons
def next

Public Attributes

 fps_limit
 lastTicks
 t_inici
 seconds
 fps
 fps_current

Static Public Attributes

int seconds = 0
 textSurface = None

Detailed Description

Calculates the frame rate (FPS), limits it and, if choosen so, displays it on screen. 

Definition at line 537 of file freevialglob.py.


Constructor & Destructor Documentation

def common.freevialglob.frameRate.__init__ (   self,
  fps_limit = 0 
)

Definition at line 543 of file freevialglob.py.

00543 
00544        def __init__( self, fps_limit = 0 ):
00545               self.fps_limit = fps_limit
00546               self.lastTicks = pygame.time.get_ticks()
00547               self.t_inici = time.time()
       

Member Function Documentation

def common.freevialglob.frameRate.next (   self,
  surface = None 
)

Definition at line 551 of file freevialglob.py.

00551 
00552        def next( self, surface = None ):
00553               
00554               if time.time() > self.seconds + 1:
00555                      self.seconds = time.time()
00556                      self.fps = self.fps_current
00557                      self.fps_current = 0
00558                      if Global.DISPLAY_FPS:
00559                             self.textSurface = render_text( 'FPS: ' + str( self.fps if self.fps > 0 else 'N/a' ), (128, 128, 128), 15, 1 )
00560               else:
00561                      self.fps_current += 1
00562               
00563               limit_fps = 1000 / self.fps_limit
00564               limit_ticks = pygame.time.get_ticks() - self.lastTicks
00565               
00566               if limit_ticks < limit_fps:
00567                      pygame.time.wait( limit_fps - limit_ticks )
00568                      self.lastTicks = pygame.time.get_ticks()
00569 
00570               if surface:   
00571                      if self.textSurface and Global.DISPLAY_FPS:
00572                             # display the frame rate on the middle of the screen's bottom
00573                             #surface.blit( self.textSurface, ( (( Global.screen_x / 2 ) - ( self.textSurface.get_width() / 2 )), 740 ) )
00574                             surface.blit( self.textSurface, (250, 740 ) )

Definition at line 548 of file freevialglob.py.

00548 
00549        def segons( self ):
00550               return time.time() - self.t_inici


Member Data Documentation

Definition at line 555 of file freevialglob.py.

Definition at line 556 of file freevialglob.py.

Definition at line 544 of file freevialglob.py.

Definition at line 545 of file freevialglob.py.

Definition at line 540 of file freevialglob.py.

Definition at line 554 of file freevialglob.py.

Definition at line 546 of file freevialglob.py.

Definition at line 541 of file freevialglob.py.


The documentation for this class was generated from the following file: