Gamestudio Links
Zorro Links
Newest Posts
Newbie Questions
by fairtrader. 12/06/23 11:29
Zorro Trader GPT
by TipmyPip. 12/04/23 11:34
Square root rule
by Smallz. 12/02/23 09:15
RTest not found error
by TipmyPip. 12/01/23 21:43
neural function for Python to [Train]
by TipmyPip. 12/01/23 14:47
Xor Memory Problem.
by TipmyPip. 11/28/23 14:23
Training with command line parameters
by TipmyPip. 11/26/23 08:42
Combine USD & BTC Pairs In Asset Loop
by TipmyPip. 11/26/23 08:30
AUM Magazine
Latest Screens
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Tactics of World War I
Who's Online Now
7 registered members (3run, miwok, AndrewAMD, Quad, TipmyPip, fairtrader, 1 invisible), 637 guests, and 2 spiders.
Key: Admin, Global Mod, Mod
Newest Members
fairtrader, hus, Vurtis, Harry5, KelvinC
19019 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 1 of 2 1 2
FPS onscreen #81262
07/13/06 14:55
07/13/06 14:55
Joined: Jul 2005
Posts: 262
Earth, The Netherlands
NL_3DGS_n00b Offline OP
Member
NL_3DGS_n00b  Offline OP
Member

Joined: Jul 2005
Posts: 262
Earth, The Netherlands
How can I display the FPS speed?
I have knowledge for making panels, but I have no idea if there is a variable to display the FPS speed etc...


The best games are the games you create yourself.
Re: FPS onscreen [Re: NL_3DGS_n00b] #81263
07/13/06 14:59
07/13/06 14:59
Joined: Feb 2003
Posts: 6,818
Minot, North Dakota, USA
ulillillia Offline
Senior Expert
ulillillia  Offline
Senior Expert

Joined: Feb 2003
Posts: 6,818
Minot, North Dakota, USA
Using time_fac is one way (multiply it by 16), but it's an abandoned variable.

Using this simple computation is another:

fps_display = pow(time_step, -1)*16;

This takes the reciprocal of the time_step variable and multiplies it by 16. This gives the frame rate. Then, just add a panel to point to this.


"You level up the fastest and easiest if you do things at your own level and no higher or lower" - useful tip My 2D game - release on Jun 13th; My tutorials
Re: FPS onscreen [Re: NL_3DGS_n00b] #81264
07/13/06 15:00
07/13/06 15:00
Joined: Jan 2004
Posts: 2,013
The Netherlands
E
Excessus Offline
Expert
Excessus  Offline
Expert
E

Joined: Jan 2004
Posts: 2,013
The Netherlands
16 / time_step

EDIT: Too late, but I think my formula is easyer to understand. pow(time_step, -1)* 16 = (time_step ^(-1)) * 16 = (1/time_step)*16 = 16 / time_step.

I don't know about speed or accuracy..

Last edited by Excessus; 07/13/06 15:04.
Re: FPS onscreen [Re: Excessus] #81265
07/13/06 15:03
07/13/06 15:03
Joined: Jul 2005
Posts: 262
Earth, The Netherlands
NL_3DGS_n00b Offline OP
Member
NL_3DGS_n00b  Offline OP
Member

Joined: Jul 2005
Posts: 262
Earth, The Netherlands
@Excessus,

Do I have to add / time_step behind *16 in 'uli's script?

(@Ulillillia, thanks, I'll try it out)


The best games are the games you create yourself.
Re: FPS onscreen [Re: NL_3DGS_n00b] #81266
07/13/06 15:05
07/13/06 15:05
Joined: Jan 2004
Posts: 2,013
The Netherlands
E
Excessus Offline
Expert
Excessus  Offline
Expert
E

Joined: Jan 2004
Posts: 2,013
The Netherlands
no, just use fps_display = 16 / time_step. Then display fps_display in a panel.

Re: FPS onscreen [Re: Excessus] #81267
07/13/06 15:08
07/13/06 15:08
Joined: Jul 2005
Posts: 262
Earth, The Netherlands
NL_3DGS_n00b Offline OP
Member
NL_3DGS_n00b  Offline OP
Member

Joined: Jul 2005
Posts: 262
Earth, The Netherlands
Do I have to define time_step somewhere before I use it? If so, what kind of value does it need?


The best games are the games you create yourself.
Re: FPS onscreen [Re: NL_3DGS_n00b] #81268
07/13/06 15:12
07/13/06 15:12
Joined: Feb 2003
Posts: 6,818
Minot, North Dakota, USA
ulillillia Offline
Senior Expert
ulillillia  Offline
Senior Expert

Joined: Feb 2003
Posts: 6,818
Minot, North Dakota, USA
Whoops! I forgot to simplify the formula, but it's still the same thing.

time_step is a predefined variable available in the 6.40.5 update. For those using older versions, use "time" instead. You do, however, have to define fps_display (or whatever you want to call it), as that isn't a predefined variable.


"You level up the fastest and easiest if you do things at your own level and no higher or lower" - useful tip My 2D game - release on Jun 13th; My tutorials
Re: FPS onscreen [Re: ulillillia] #81269
07/13/06 15:25
07/13/06 15:25
Joined: Jul 2005
Posts: 262
Earth, The Netherlands
NL_3DGS_n00b Offline OP
Member
NL_3DGS_n00b  Offline OP
Member

Joined: Jul 2005
Posts: 262
Earth, The Netherlands
I placed fps_display = 16 / time; inside a while(1){ } with a wait(64); inside a function so it won't refresh to fast.
Now I see it switches from 200 to 256. So I think it works?


The best games are the games you create yourself.
Re: FPS onscreen [Re: NL_3DGS_n00b] #81270
07/13/06 15:29
07/13/06 15:29
Joined: Jan 2004
Posts: 2,013
The Netherlands
E
Excessus Offline
Expert
Excessus  Offline
Expert
E

Joined: Jan 2004
Posts: 2,013
The Netherlands
Yes that should do it, although it's never a good idea to use wait(x) for a timed interval. Better use wait(-x) to wait x seconds instead of x frames because the time of a frame is variable.

If you want to check if the value of your calculated fps is correct, press f11 to bring up the debug panel and compare the values (they may slightly differ because of limited var accuracy)

Re: FPS onscreen [Re: Excessus] #81271
07/13/06 15:33
07/13/06 15:33
Joined: Jul 2005
Posts: 262
Earth, The Netherlands
NL_3DGS_n00b Offline OP
Member
NL_3DGS_n00b  Offline OP
Member

Joined: Jul 2005
Posts: 262
Earth, The Netherlands
Thanks, I'll check it out.

EDIT:

This is the script I'm using now, it works fine now:

Code:
function fps_show{
if(FPS.visible == off){
FPS.visible = on;
while(FPS.visible == on){
fps_display = 16 / time;
wait(1);
}
}else{
FPS.visible = off;
}
}

on_f = fps_show;



Last edited by NL_3DGS_n00b; 07/13/06 15:40.

The best games are the games you create yourself.
Page 1 of 2 1 2

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1