|
Something interesting...
#289921
09/16/09 10:42
09/16/09 10:42
|
Joined: Apr 2009
Posts: 248 Philippines
seecah
OP
Member
|
OP
Member
Joined: Apr 2009
Posts: 248
Philippines
|
Could anybody try this code:
#include<acknex.h>
#include<default.c>
var testing = 0;
PANEL* backgrnd =
{
layer = -998;
digits(400, 500, "Frame Rate: %3.5f", *, 1, testing);
digits(400, 530, "Time Step: %3.5f", *, 1, time_step);
flags = SHOW;
}
void main()
{
fps_max = 60;
video_set(1024, 768, 32, 2);
sky_color.red = 0;
sky_color.green = 0;
sky_color.blue = 0;
testing = (float)(16/time_step);
level_load("");
}
I can get an output of Frame Rate: 123.18750 Time Step: 0.26660 But where did the engine get a value of 123.18750 if 16/0.26660 = 60.015 If anybody knows why, maybe I need an explanation... I've tried to cast everything to float but still the output is the same? Why?
Can't is not an option™
|
|
|
Re: Something interesting...
[Re: seecah]
#289935
09/16/09 11:50
09/16/09 11:50
|
Joined: Feb 2008
Posts: 3,232 Australia
EvilSOB
Expert
|
Expert
Joined: Feb 2008
Posts: 3,232
Australia
|
Change your code to this and try it again. Then, if you cant see whats happened, or why, post and ask. I wont be far away...
var testing = 0;
var test_time = 0;
PANEL* backgrnd =
{
layer = -998;
digits(400, 500, "Frame Rate: %3.5f", *, 1, testing);
digits(400, 530, "Time Step: %3.5f", *, 1, test_time);
flags = SHOW;
}
void main()
{
fps_max = 60;
video_set(1024, 768, 32, 2);
sky_color.red = 0;
sky_color.green = 0;
sky_color.blue = 0;
testing = (float)(16/time_step);
test_time = time_step;
level_load("");
}
"There is no fate but what WE make." - CEO Cyberdyne Systems Corp. A8.30.5 Commercial
|
|
|
Re: Something interesting...
[Re: EvilSOB]
#289938
09/16/09 12:11
09/16/09 12:11
|
Joined: Apr 2009
Posts: 248 Philippines
seecah
OP
Member
|
OP
Member
Joined: Apr 2009
Posts: 248
Philippines
|
Hi EvilSOB, Thanks for the response.. you are always there when I posts a problem... Just now I found out that I have receive that strange value because when the engine executes testing = (float)(16/time_step); it is not yet the updated frame rate being used.. I've tried to modify the code and put a wait function before the manipulation
fps_max = 75;
video_set(1024, 768, 32, 2);
sky_color.red = 0;
sky_color.green = 0;
sky_color.blue = 0;
wait(5);
testing = (float)(16/time_step);
level_load("");
or simply put the testing = (float)(16/time_step); inside a while loop and it will works fine.. Thanks
Can't is not an option™
|
|
|
Re: Something interesting...
[Re: seecah]
#289941
09/16/09 12:24
09/16/09 12:24
|
Joined: Feb 2008
Posts: 3,232 Australia
EvilSOB
Expert
|
Expert
Joined: Feb 2008
Posts: 3,232
Australia
|
Im not always there when you post a problem... Im just ALWAYS THERE !
I'd suggest to go with the loop option. If you only calculate the FPS once, and it "happens" to be either a "quiet" ro "busy" frame, it will give you a skewed value.
Anyhow, here is an untested bastardisation of the smoothed FPS calculator used by the 'default.c' debug-panel. fps = 0.9 * fps + 0.1 / time_frame; BTW, it gets updated once a frame, so put it in a while-loop with a wait(1) and it should calculate correctly.
"There is no fate but what WE make." - CEO Cyberdyne Systems Corp. A8.30.5 Commercial
|
|
|
Re: Something interesting...
[Re: EvilSOB]
#290059
09/17/09 04:19
09/17/09 04:19
|
Joined: Aug 2008
Posts: 482
bart_the_13th
Senior Member
|
Senior Member
Joined: Aug 2008
Posts: 482
|
Isn't there a 'time_smooth' variable that can be used for that? Just set
|
|
|
Re: Something interesting...
[Re: bart_the_13th]
#290065
09/17/09 05:09
09/17/09 05:09
|
Joined: Feb 2008
Posts: 3,232 Australia
EvilSOB
Expert
|
Expert
Joined: Feb 2008
Posts: 3,232
Australia
|
Probably, but remember I didnt WRITE this code, just improved the variable name. And its simple enough as is, and works well enough, so why make things more complex by trying to crowbar time_smooth in there?
"There is no fate but what WE make." - CEO Cyberdyne Systems Corp. A8.30.5 Commercial
|
|
|
|