Gamestudio Links
Zorro Links
Newest Posts
Bug in train mode, or it seem to me
by jcl. 09/22/26 14:47
Sam Foster Sound | Experienced Game Composer for Hire
by titanicpiano14. 09/22/26 12:21
Capital slider is not saving in Z12
by Petra. 09/22/26 06:49
Parent/child object
by VoroneTZ. 09/22/26 05:52
Zorro tutorial ideas?
by AndrewAMD. 09/21/26 14:50
Trades during a running bar
by Martin_HH. 09/21/26 12:03
Avoiding pop-up training parameter results
by Martin_HH. 09/16/26 21:31
AUM Magazine
Latest Screens
Dorifto samurai
Shadow 2
Rocker`s Revenge
Stug 3 Stormartillery
Who's Online Now
0 registered members (), 1,799 guests, and 2 spiders.
Key: Admin, Global Mod, Mod
Newest Members
Opus, Jubilee, lopezsergio07, mistery, lokkalyansamiti
19239 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