Author Topic: LIMITFPS -1  (Read 2327 times)

Offline MrPlow

  • Prof. Inline
  • *****
  • Posts: 1785
    • View Profile
LIMITFPS -1
« 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?

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

MrTAToad

  • Guest
Re: LIMITFPS -1
« Reply #1 on: 2013-Dec-03 »
I presume my last message helped...  Let me know if you need some example code.

Offline spacefractal

  • Community Developer
  • Prof. Inline
  • ******
  • Posts: 3958
    • View Profile
    • Space Fractal
Re: LIMITFPS -1
« Reply #2 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.
Genius.Greedy Mouse - Karma Miwa - Spot Race - CatchOut - PowerUp Elevation and The beagle Jam.

Offline MrPlow

  • Prof. Inline
  • *****
  • Posts: 1785
    • View Profile
Re: LIMITFPS -1
« Reply #3 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






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

Offline Darmakwolf

  • Dr. Type
  • ****
  • Posts: 361
  • Aoooooooo - the werewolves of London!
    • View Profile
Re: LIMITFPS -1
« Reply #4 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

Offline MrPlow

  • Prof. Inline
  • *****
  • Posts: 1785
    • View Profile
LIMITFPS -1
« Reply #5 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

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

MrTAToad

  • Guest
Re: LIMITFPS -1
« Reply #6 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

Offline kanonet

  • Administrator
  • Prof. Inline
  • *******
  • Posts: 1137
    • View Profile
    • My GLBasic code archiv
Re: LIMITFPS -1
« Reply #7 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.
Lenovo Thinkpad T430u: Intel i5-3317U, 8GB DDR3, NVidia GeForce 620M, Micron RealSSD C400 @Win7 x64