LIMITFPS -1

Previous topic - Next topic

MrPlow

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?

Comp:
Speccy-48k, Speccy-128k, Amigas, PCs

MrTAToad

I presume my last message helped...  Let me know if you need some example code.

spacefractal

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.
Genius.Greedy Mouse - Karma Miwa - Spot Race - CatchOut - PowerUp Elevation - The beagle Jam - Cave Heroes 2023 - https://spacefractal.itch.io/

MrPlow

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






Comp:
Speccy-48k, Speccy-128k, Amigas, PCs

Darmakwolf

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

MrPlow

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

Comp:
Speccy-48k, Speccy-128k, Amigas, PCs

MrTAToad

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

kanonet

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.
Lenovo Thinkpad T430u: Intel i5-3317U, 8GB DDR3, NVidia GeForce 620M, Micron RealSSD C400 @Win7 x64