Got an iPhone or iPad? We have a brand new Pastebin App for both devices, and it's totally free! Click here to download the new Pastebin App for iOS.
Guest

emachine74

By: a guest on Feb 24th, 2008  |  syntax: VB.NET  |  size: 0.73 KB  |  hits: 55  |  expires: Never
download  |  raw  |  embed  |  report abuse
Copied
  1. Public Class Fps
  2.  
  3.     '...other stuff omitted, this class
  4.     'inherits from a sprite-like class
  5.     'I use for displaying text...
  6.  
  7.     Private intFrames As Integer
  8.     Private objTime As TimeSpan
  9.  
  10.     Public Overrides Sub Update()
  11.  
  12.         'Count this frame
  13.         Me.intFrames += 1
  14.  
  15.         'Accumulate time elapsed
  16.         Me.objTime += Me.Game.GameTime.ElapsedRealTime
  17.  
  18.         'Has 1 second elapsed since I last reset?
  19.         If Me.objTime.TotalSeconds >= 1 Then
  20.            
  21.             'Output the fps
  22.             Me.SetText("fps: " & Me.intFrames.ToString)
  23.  
  24.             'Reset frames & time elapsed
  25.             Me.intFrames = 0
  26.             Me.objTime = TimeSpan.Zero
  27.  
  28.         End If
  29.  
  30.     End Sub
  31.  
  32. End Class