GLBasic forum

Main forum => GLBasic - en => Topic started by: MrPlow on 2013-Dec-01

Title: LIMITFPS -1
Post by: MrPlow on 2013-Dec-01
Hi Can anyone help on this,

How do I implement this with the Apptimer routine so that I get consistent 60 FPS and not have to use LIMITFPS 60?

Title: Re: LIMITFPS -1
Post by: MrTAToad on 2013-Dec-03
I presume my last message helped...  Let me know if you need some example code.
Title: Re: LIMITFPS -1
Post by: spacefractal on 2013-Dec-04
Some sort of this?

Code (glbasic) Select

FUNCTION  update_Delay: displayUpdateFreq=60
LOCAL a=0
STATIC reset=1
STATIC lasttimer=0
IF reset=1
reset=0
lasttimer=GETTIMERALL()
ENDIF
LOCAL update=1000/displayUpdateFreq
LOCAL mstimerticks=(GETTIMERALL()-lasttimer)
lasttimer=GETTIMERALL()
LOCAL updatedelay=mstimerticks/update
IF GameFade<1 THEN RETURN displayUpdateFreq/INTERFPS
RETURN updatedelay
ENDFUNCTION


This return how many frames that have been since the last frame as a float. Etc GETTIMERALL() is your friend doing timers without having sort to LIMITFPS.
Title: Re: LIMITFPS -1
Post by: MrPlow on 2013-Dec-04
Hmmm, I need to look at this again...

I am getting really odd results with my implementation...I think its down to my RND() functions...

They work well based on the LIMITFPS 60 but when I run with -1 the RND() values obviously loop much more (due to PC speed) and have far higher chances of occurance...

So my RND() functions need to be limited too but not sure how...?!?! Cant really apply speed to interactive actions like RND()s within loops until I only run the loop when FPS = 60??! Which may cause unexpected results

So in psuedo logic

LIMITFPS 60
WHILE FPS=60
           DO Random actions // limited loops
WEND

LIMITFPS -1
WHILE TRUE

          DO Random actions much more freq... //+++ Loops more and condition is met more

WEND






Title: Re: LIMITFPS -1
Post by: Darmakwolf on 2013-Dec-04
Quote from: MrPlow on 2013-Dec-04
Hmmm, I need to look at this again...

I am getting really odd results with my implementation...I think its down to my RND() functions...

They work well based on the LIMITFPS 60 but when I run with -1 the RND() values obviously loop much more (due to PC speed) and have far higher chances of occurance...

So my RND() functions need to be limited too but not sure how...?!?! Cant really apply speed to interactive actions like RND()s within loops until I only run the loop when FPS = 60??! Which may cause unexpected results

So in psuedo logic

LIMITFPS 60
WHILE FPS=60
           DO Random actions // limited loops
WEND

LIMITFPS -1
WHILE TRUE

          DO Random actions much more freq... //+++ Loops more and condition is met more

WEND


I feel like that's ... not a good idea. Just my observation. I don't use any weird timing routines, but what I'd do is use loops to determine how many times something happens per frame. I'd handle it like this.

while true
local l%

for l = 0 to 10
//do lots of random stuff
next

for l = 0 to 2
//do less random stuff
next

wend
Title: LIMITFPS -1
Post by: MrPlow on 2013-Dec-04
Yes, but those loops are with the whole game loop and that is where I have the problem


Limitfps 60 - 1000 loops example

Limitfps -1   - 10000 loops on fast PC

Title: Re: LIMITFPS -1
Post by: MrTAToad on 2013-Dec-05
My AppTimer routine here (http://www.glbasic.com/forum/index.php?topic=3384.msg33889#msg33889) has an example on how use it.

The basic idea is that when you calculate the time between any two SHOWSCREENs the value is used as a factor of all movement, so the faster the machine the slower the steps
Title: Re: LIMITFPS -1
Post by: kanonet on 2013-Dec-05
BTW if your game runs very fast, its pointless to render 500 FPS etc... so if you use LIMITFPS -1 plz use SLEEP and give back some CPU time to save battery power and allow the CPU fan to stay calm.