Graal Forums  

Go Back   Graal Forums > Development Forums > NPC Scripting > Code Gallery
FAQ Members List Calendar Today's Posts

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 01-04-2010, 03:03 PM
DustyPorViva DustyPorViva is offline
Will work for food. Maybe
DustyPorViva's Avatar
Join Date: Sep 2003
Location: Maryland, USA
Posts: 9,589
DustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond repute
Send a message via AIM to DustyPorViva Send a message via MSN to DustyPorViva
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);


And in a level with 1024 images being displayed, running at a low fps:
Reply With Quote
  #2  
Old 01-06-2010, 12:50 AM
DustyPorViva DustyPorViva is offline
Will work for food. Maybe
DustyPorViva's Avatar
Join Date: Sep 2003
Location: Maryland, USA
Posts: 9,589
DustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond repute
Send a message via AIM to DustyPorViva Send a message via MSN to DustyPorViva
Bump, since I posted this right before the forums went down.
Reply With Quote
  #3  
Old 01-06-2010, 01:15 AM
Tigairius Tigairius is offline
The Cat
Tigairius's Avatar
Join Date: Jan 2007
Location: Missouri, USA
Posts: 4,240
Tigairius has a brilliant futureTigairius has a brilliant futureTigairius has a brilliant futureTigairius has a brilliant futureTigairius has a brilliant futureTigairius has a brilliant futureTigairius has a brilliant futureTigairius has a brilliant future
I was thinking about a way to calculate framerate and thought about this the other night, it's convenient that you actually made it

Cool contribution.
__________________


“Shoot for the moon. Even if you miss, you'll land among the stars.”
Reply With Quote
  #4  
Old 01-06-2010, 05:47 AM
12171217 12171217 is offline
Banned
Join Date: Jan 2009
Posts: 453
12171217 has a spectacular aura about
Glad to see I sparked your inspiration

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.

Last edited by 12171217; 01-06-2010 at 05:48 AM.. Reason: Code tags replaced with php tags, code tags expand it, ewwww
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


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


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