Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   Code Gallery (https://forums.graalonline.com/forums/forumdisplay.php?f=179)
-   -   Frames-Per-Second (https://forums.graalonline.com/forums/showthread.php?t=134257538)

DustyPorViva 01-04-2010 03:03 PM

Frames-Per-Second
 
A small script I wrote up yesterday after the idea was sparked by Downsider.
Alt+f toggles it on and off:
PHP Code:

//#CLIENTSIDE
function onCreated() {
  
this.updatespeed .5;  // SPEED THAT THE FRAMERATE IS CHECKED, > 0.05
  
setTimer(0.05);
}

function 
onKeyPressed(keycode) {
  if (
keycode == 1094) {                // OPENS WITH ALT+F
    
player.showfps = !player.showfps;
    
this.oldtimevar2 timevar2 0.05// START CHECK A FRAME BEHIND
    
setTimer(0.05);
  }
}

function 
onTimeout() {
  if (!
player.showfps) {
    
hideimg(200);
    return;
  } 
  
temp.framediff = (@timevar2-this.oldtimevar2).substring(0,5)/this.updatespeed;
  
temp.framerate int((1/framediff)*20+.5);
  
// FRAME RATE CAN NOT EXCEED 20 OR HIT 0
  
if (framerate 20 || framerate == 0framerate 20;
  
with (findimg(200)) {
    
GUIContainer.width-150;
    
GUIContainer.height-75;
    
font $pref::graal::defaultfontname;
    
zoom $pref::graal::defaultfontsize/24;
    
layer 4;
    
textshadow true;
    
text "f: " framerate;
  }
  
this.oldtimevar2 timevar2;
  
setTimer(this.updatespeed);


http://i50.tinypic.com/raasdj.png
And in a level with 1024 images being displayed, running at a low fps:
http://i45.tinypic.com/10ifk9x.png

DustyPorViva 01-06-2010 12:50 AM

Bump, since I posted this right before the forums went down.

Tigairius 01-06-2010 01:15 AM

I was thinking about a way to calculate framerate and thought about this the other night, it's convenient that you actually made it :D

Cool contribution.

12171217 01-06-2010 05:47 AM

Glad to see I sparked your inspiration :D

If anyone's interested, here's mine, was made, again, for version 2.2; just a version short of timevar2 being implemented:

PHP Code:

if (playerenters) {
  
play framerate_silent.mp3;
  
timeout 0.05;
}

if (
timeout) {
  if (
musicpos == 0) {
    
play framerate_silent.mp3;
  }
  
this.frame+=0.05;
  if (
musicpos 1) {
    
this.framerate  this.frame/musicpos;
    
stopmidi;
    
this.frame = -0.05;
  }
  
showtext 300,15,128,Arial,,Framerate#v(this.framerate*20);
  
changeimgvis 300,8;
  
timeout 0.05;


Kinda interesting to see the workaround used, haha.


All times are GMT +2. The time now is 12:21 AM.

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2026, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.