FPS counter

Übersicht BlitzMax, BlitzMax NG Codearchiv & Module

Neue Antwort erstellen

beanage.johannes

Betreff: FPS counter

BeitragDo, Aug 06, 2009 17:09
Antworten mit Zitat
Benutzer-Profile anzeigen
ein simpler fps counter wenn man grad zu faul ist sich flott selber einen zu schreiben^^
Code: [AUSKLAPPEN]
Type TFps   

   Field Old:Int
   Field Fps:Int

   Field count:Int
   Field time:Int
   
   Field timer:TTimer

   Function Create:TFps()
   
      Local n:TFps = New TFps
      
         n.timer = CreateTimer(1)
         
      Return n
   
   EndFunction
   
   Method Reset()
   
      time = 0
      count = 0
      fps = 0
      old = 0
   
   EndMethod
   
   Method Update()
   
   count:+ 1
   time = TimerTicks(timer) Mod 2
   
      If time <> old Then
         fps = count
         count = 0
         old = time
      EndIf
   
   EndMethod
   
   Method Get:Int()
   
      Return fps
   
   EndMethod

EndType


und ein kleines beispiel...
Code: [AUSKLAPPEN]

graphics 640,480

fps:TFps = TFps.Create()

repeat
cls

drawtext "fps: " + string(fps.get),5,5

fps.Update()
flip(0)
until keydown(key_escape)
  • Zuletzt bearbeitet von beanage.johannes am Di, Aug 18, 2009 21:08, insgesamt einmal bearbeitet

Mathias-Kwiatkowski

BeitragFr, Aug 14, 2009 4:41
Antworten mit Zitat
Benutzer-Profile anzeigen
bei mir funtzt des net...



fps.TFps = TFps.Create()

Compile Error: Identifier 'TFps' not found
Build Error: failed to compile C:/Programme/BLIde for BlitzMax/tmp/bmx_file.bmx
 

klepto2

BeitragFr, Aug 14, 2009 8:45
Antworten mit Zitat
Benutzer-Profile anzeigen
Local fps:TFPS = TFPS.Create()

Hat sich wohl ein kleiner Fehler in den sample Code eingeschlichen Smile
Matrix Screensaver
Console Modul für BlitzMax
KLPacker Modul für BlitzMax

HomePage : http://www.brsoftware.de.vu

Nicdel

BeitragFr, Aug 14, 2009 8:45
Antworten mit Zitat
Benutzer-Profile anzeigen
Versuchs mal so:

BlitzMax: [AUSKLAPPEN]
fps:TFps = TFps.Create() 
Desktop: Intel Pentium 4 2650 Mhz, 2 GB RAM, ATI Radeon HD 3850 512 MB, Windows XP
Notebook: Intel Core i7 720 QM 1.6 Ghz, 4 GB DDR3 RAM, nVidia 230M GT, Windows 7

Mathias-Kwiatkowski

BeitragDi, Aug 18, 2009 1:54
Antworten mit Zitat
Benutzer-Profile anzeigen
Graphics 640, 480

Local fps:TFps = TFps.Create()

repeat
cls

drawtext "fps: " + string(fps.get),5,5

fps.Update()
flip(0)
until keydown(key_escape)

->

Compile Error: Unable to convert from 'Int()' to 'String'
Build Error: failed to compile C:/Programme/BLIde for BlitzMax/tmp/bmx_file.bmx


funktioniert alles nich so wirklich O.o

Xeres

Moderator

BeitragDi, Aug 18, 2009 2:13
Antworten mit Zitat
Benutzer-Profile anzeigen
BlitzMax: [AUSKLAPPEN]
fps.get()
Die Klammern sind nicht unwichtig...
Win10 Prof.(x64)/Ubuntu 16.04|CPU 4x3Ghz (Intel i5-4590S)|RAM 8 GB|GeForce GTX 960
Wie man Fragen richtig stellt || "Es geht nicht" || Video-Tutorial: Sinus & Cosinus
T
HERE IS NO FAIR. THERE IS NO JUSTICE. THERE IS JUST ME. (Death, Discworld)

beanage.johannes

BeitragDi, Aug 18, 2009 21:08
Antworten mit Zitat
Benutzer-Profile anzeigen
habe den fehler im beispiel ausgebessert^^ danke

müsste mit klammern eigentlich funzen Smile

Neue Antwort erstellen


Übersicht BlitzMax, BlitzMax NG Codearchiv & Module

Gehe zu:

Powered by phpBB © 2001 - 2006, phpBB Group