Gamestudio Links
Zorro Links
Newest Posts
Zorro 2.70
by jcl. 09/29/25 09:24
optimize global parameters SOLVED
by dBc. 09/27/25 17:07
ZorroGPT
by TipmyPip. 09/27/25 10:05
assetHistory one candle shift
by jcl. 09/21/25 11:36
Plugins update
by Grant. 09/17/25 16:28
AUM Magazine
Latest Screens
Rocker`s Revenge
Stug 3 Stormartillery
Iljuschin 2
Galactic Strike X
Who's Online Now
2 registered members (AndrewAMD, TipmyPip), 12,709 guests, and 5 spiders.
Key: Admin, Global Mod, Mod
Newest Members
krishna, DrissB, James168, Ed_Love, xtns
19168 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