Author Topic: Re: FPS Delay  (Read 691 times)

0 Members and 1 Guest are viewing this topic.

Offline SMcNeill

  • QB64 Developer
  • Forum Resident
  • Posts: 3972
    • View Profile
    • Steve’s QB64 Archive Forum
Re: FPS Delay
« on: January 04, 2019, 07:59:07 pm »
Just use _LIMIT.

T# = TIMER
DO
    _LIMIT 60 ‘60 frames per second
    IF TIMER - T# > 1 THEN
        T# = TIMER
        LOCATE 1,1: PRINT FPS
        FPS = 0
   END IF
LOOP UNTIL _KEYHIT
https://github.com/SteveMcNeill/Steve64 — A github collection of all things Steve!

Offline SMcNeill

  • QB64 Developer
  • Forum Resident
  • Posts: 3972
    • View Profile
    • Steve’s QB64 Archive Forum
Re: FPS Delay
« Reply #1 on: January 04, 2019, 10:23:09 pm »


T# = TIMER
DO
    _LIMIT 60 ‘60 frames per second
    FPS = FPS + 1
    IF TIMER - T# > 1 THEN
        T# = TIMER
        LOCATE 1,1: PRINT FPS
        FPS = 0
   END IF
LOOP UNTIL _KEYHIT




Sorry.  Left the counter out.
https://github.com/SteveMcNeill/Steve64 — A github collection of all things Steve!

Offline Pete

  • Forum Resident
  • Posts: 2361
  • Cuz I sez so, varmint!
    • View Profile
Re: FPS Delay
« Reply #2 on: January 04, 2019, 11:01:37 pm »
Of course don't run that code at midnight!

I use abs(timer -t#) to fudge that a bit, but you need to use 86,400 seconds in a 24-hour day to get code that will adjust properly at midnight for fully reliable timer applications.

So when timer becomes less than t#, which happens right after midnight, t# = t# - 86400.

Pete
Want to learn how to write code on cave walls? https://www.tapatalk.com/groups/qbasic/qbasic-f1/

Offline SMcNeill

  • QB64 Developer
  • Forum Resident
  • Posts: 3972
    • View Profile
    • Steve’s QB64 Archive Forum
Re: FPS Delay
« Reply #3 on: January 04, 2019, 11:12:39 pm »
Of course don't run that code at midnight!

I use abs(timer -t#) to fudge that a bit, but you need to use 86,400 seconds in a 24-hour day to get code that will adjust properly at midnight for fully reliable timer applications.

So when timer becomes less than t#, which happens right after midnight, t# = t# - 86400.

Pete

Plug in the ExtendedTimer: http://qb64.freeforums.net/thread/20/extended-timer-uet
https://github.com/SteveMcNeill/Steve64 — A github collection of all things Steve!