Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Professional Discussion / Make SCREEN FPS() to return wrong values

Author
Message
Zero
21
Years of Service
User Offline
Joined: 28th Aug 2002
Location: Finland
Posted: 25th Oct 2002 17:01
This is a very weird bug I found when fooling around with fps-independent movement.
It seems that DBPro will return insanely high FPS values if you have used SCREEN FPS()
command in statements before. This doesn't mean that the actual performance of the
application will increase at all. In spite of SCREEN FPS() lies to us, the real FPS that we
can't know will be the same and this will screw up the ratios which are needed to build
a fixed movement values.

Please don't say I should use timer() instead. It is not the point of this topic.

OK.. I have a proof on this. I have two very similar programs. First try this one:



sync on
sync rate 0
dim PlayerSpeed#(0)

color backdrop rgb(16,16,16)

do

PlayerPlusX#=sin(wrapValue(HeadingAngleWhenPressed#+PlayerStrafing#))*PlayerSpeed#(0) :`*(75.0/(screen fps()+0.001))
PlayerPlusZ#=cos(wrapValue(HeadingAngleWhenPressed#+PlayerStrafing#))*PlayerSpeed#(0) :`*(75.0/(screen fps()+0.001))

NewCameraX#=curvevalue(1.0,oldCameraX#,2.0) :`*((screen fps()+0.001)/60.0))
NewCameraZ#=curvevalue(1.0,oldCameraZ#,2.0) :`*((screen fps()+0.001)/60.0))

NewStickX#=curvevalue(1.0,oldStickX#,3.5) :`*((screen fps()+0.001)/60.0))
NewStickZ#=curvevalue(1.0,oldStickZ#,3.5) :`*((screen fps()+0.001)/60.0))

cls

ink rgb(255,255,255),1
set cursor 0,0
print screen fps()

sync

loop

end



Mark up that there are a couple of lines with the end of it commented which will ignore
SCREEN FPS() command in the statement. Nothing unusual there. Take the next example:


sync on
sync rate 0
dim PlayerSpeed#(0)

color backdrop rgb(16,16,16)

do

PlayerPlusX#=sin(wrapValue(HeadingAngleWhenPressed#+PlayerStrafing#))*PlayerSpeed#(0) *(75.0/(screen fps()+0.001))
PlayerPlusZ#=cos(wrapValue(HeadingAngleWhenPressed#+PlayerStrafing#))*PlayerSpeed#(0) *(75.0/(screen fps()+0.001))

NewCameraX#=curvevalue(1.0,oldCameraX#,2.0 *((screen fps()+0.001)/60.0))
NewCameraZ#=curvevalue(1.0,oldCameraZ#,2.0 *((screen fps()+0.001)/60.0))

NewStickX#=curvevalue(1.0,oldStickX#,3.5 *((screen fps()+0.001)/60.0))
NewStickZ#=curvevalue(1.0,oldStickZ#,3.5 *((screen fps()+0.001)/60.0))

cls

ink rgb(255,255,255),1
set cursor 0,0
print screen fps()

sync

loop

end



Now I have taken the SCREEN FPS() command within and it's now a part of the statement.
The first example ran me at 62 fps solid. The I tried the second one and got about 470 fps solid!

AMAZING!

BUT it is not the true value! I really don't know why this happens, but it's very odd indeed!
The evil plan is now even closer!
- - - - - - - - - - - - - - - - - - - -
Specs:- P3 550 Nvidia TNT2M64, 192Mb RAM
haggisman
21
Years of Service
User Offline
Joined: 26th Aug 2002
Location: United Kingdom
Posted: 25th Oct 2002 19:03
don't use the command screen fps() more than once if you dont have to:



I believe that will give approx the same as the first one, but what is most bizare is every time you use the screen fps() command it adds onto itself, so if the actual fps was 60 and you use the command 3 times then the displayed value will be 3X60=180. I think it needs fixing

Specs:- 1GHZ athlon, Radeon8500, 192mb ram, winxp
Mike Johnson
TGC Developer
21
Years of Service
User Offline
Joined: 13th Sep 2002
Location: United Kingdom
Posted: 25th Oct 2002 19:41
This is a bug. The "screen fps ( )" command is only meant to be called once per program loop.

Mike
Zero
21
Years of Service
User Offline
Joined: 28th Aug 2002
Location: Finland
Posted: 25th Oct 2002 20:35
But it is a value returning function! How calling it more than once would ever affect to it?!

Is it possible to fix?

The evil plan is now even closer!
- - - - - - - - - - - - - - - - - - - -
Specs:- P3 550 Nvidia TNT2M64, 192Mb RAM
Zero
21
Years of Service
User Offline
Joined: 28th Aug 2002
Location: Finland
Posted: 25th Oct 2002 20:36
So you could first call it by fps=screen fps()
and then use fps variable for the other spots in the program

The evil plan is now even closer!
- - - - - - - - - - - - - - - - - - - -
Specs:- P3 550 Nvidia TNT2M64, 192Mb RAM
Mike Johnson
TGC Developer
21
Years of Service
User Offline
Joined: 13th Sep 2002
Location: United Kingdom
Posted: 25th Oct 2002 21:58
It is possible to fix. It's just that when you call that function it handles some timer operations so it's best call it once for now and store that value in a variable. We can fix this problem in the future.

Mike
DrakeX
21
Years of Service
User Offline
Joined: 26th Aug 2002
Location:
Posted: 26th Oct 2002 00:57
it calculates the FPS since it was last called. like MOUSEMOVEX() will.

so only call it once per loop using haggisman's workaround.

i'm looking at yooooou!
rapscaLLion
21
Years of Service
User Offline
Joined: 29th Aug 2002
Location: Canada
Posted: 26th Oct 2002 03:02
interesting, to say the least

Alex Wanuch
aka rapscaLLion
Get the DB Weekly Newsletter at www.dbwn.cjb.net

Login to post a reply

Server time is: 2024-03-29 05:40:10
Your offset time is: 2024-03-29 05:40:10