Gamestudio Links
Zorro Links
Newest Posts
Camera always moves upwards?
by clonman. 11/13/25 14:04
brokerCommand PLOT_HLINE parameters
by M_D. 11/13/25 10:42
ZorroGPT
by TipmyPip. 11/10/25 11:04
Training with the R bridge does not work
by frutza. 11/05/25 00:46
Zorro 2.70
by opm. 10/24/25 03:44
Alpaca Plugin v1.4.0
by TipmyPip. 10/20/25 18:04
AUM Magazine
Latest Screens
Rocker`s Revenge
Stug 3 Stormartillery
Iljuschin 2
Galactic Strike X
Who's Online Now
5 registered members (Grant, AndrewAMD, ozgur, Quad, TipmyPip), 29,980 guests, and 3 spiders.
Key: Admin, Global Mod, Mod
Newest Members
sheliepaley, Blueguy, blobplayintennis, someone2, NotEBspark
19177 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
FPS variable and _chr #390614
01/03/12 04:24
01/03/12 04:24
Joined: Mar 2009
Posts: 186
V
Valdsator Offline OP
Member
Valdsator  Offline OP
Member
V

Joined: Mar 2009
Posts: 186
Hello. Is there a variable in 3DGS that stores the current frames per second? If not, how could I make one?

Also, I'm trying to code in customization of the controls, and I tried to do this by having strings like key_forw, for moving forward. Then I set the string to "key_w," and whenever key_forw was needed, I used engine_getscript(_chr(key_forw)), which, if I understand correctly, is supposed to use the contents of the string as code.

This didn't work, so how should I accomplish this?

Thank you!

Re: FPS variable and _chr [Re: Valdsator] #390625
01/03/12 11:26
01/03/12 11:26
Joined: Apr 2007
Posts: 3,751
Canada
WretchedSid Offline
Expert
WretchedSid  Offline
Expert

Joined: Apr 2007
Posts: 3,751
Canada
Code:
var fps = 1 / (time_frame / 16);
// You divide by 16 because time_frame gets multiplied by 16
// And you use time_frame because time_step doesn't always contain the time the last frame needed to render



About your second question, no, there is no way to use the content of a cstring as code! engine_getscript() simply returns the pointer to the function with the given name, that you can then invoke. However, I would use something different since calling engine_getscript() every keystroke is probably pretty slow.


Shitlord by trade and passion. Graphics programmer at Laminar Research.
I write blog posts at feresignum.com
Re: FPS variable and _chr [Re: WretchedSid] #390631
01/03/12 13:24
01/03/12 13:24
Joined: Mar 2011
Posts: 3,150
Budapest
sivan Offline
Expert
sivan  Offline
Expert

Joined: Mar 2011
Posts: 3,150
Budapest
hi

when you press F11, you can see the fps, which is calculated as (copied from default.c):

def_dfps = 0.9*def_dfps+0.1/time_frame;

(for me "var fps = 1 / (time_frame / 16);" does not work properly)


Last edited by sivan; 01/03/12 13:27.

Free world editor for 3D Gamestudio: MapBuilder Editor
Re: FPS variable and _chr [Re: sivan] #390681
01/03/12 20:57
01/03/12 20:57
Joined: Mar 2009
Posts: 186
V
Valdsator Offline OP
Member
Valdsator  Offline OP
Member
V

Joined: Mar 2009
Posts: 186
Originally Posted By: sivan
(for me "var fps = 1 / (time_frame / 16);" does not work properly)

It seems to work fine for me, but I'll try your method if I run in to issues.
Thank you two for the help!


Gamestudio download | 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