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.

AppGameKit Classic Chat / High Precision Timer in Tier 1

Author
Message
nz0
AGK Developer
17
Years of Service
User Offline
Joined: 13th Jun 2007
Location: Cheshire,UK
Posted: 27th May 2014 03:20
Is there going to be any chance of getting access to high precision timers in V2?

I'm guessing that they don't exist on mobile devices, but could be exposed on PC/MAC or devices that support it?

JimHawkins
15
Years of Service
User Offline
Joined: 26th Jul 2009
Location: Hull - UK
Posted: 27th May 2014 09:28
Android has millisecond and nanosecond timers available.

-- Jim - When is there going to be a release?
Markus
Valued Member
20
Years of Service
User Offline
Joined: 10th Apr 2004
Location: Germany
Posted: 27th May 2014 09:38
i think u can reset the timer , it get precision again.
or GetFrameTime().
why u need this?
the only usage i had myself with it was check the running time
for functions, for optimize then.

AGK 108 (B)19 : Windows 8.1 Pro 64 Bit : AMD Radeon HD 6670
Paul Johnston
TGC Developer
22
Years of Service
User Offline
Joined: 16th Nov 2002
Location: United Kingdom
Posted: 27th May 2014 15:03
The Timer() command uses the highest precision timer that I know of for each platform
nz0
AGK Developer
17
Years of Service
User Offline
Joined: 13th Jun 2007
Location: Cheshire,UK
Posted: 27th May 2014 16:54
I want to be able to tighten my frame based movement system.
I posted that I found a new problem when I got a new PC and my game went to over 1000fps. Well, with only millisecond precision, you can see that granularity is lost.

I posted about this in this thread, as I found that I had a -1.#IND00 value breaking my timer.

Of course, if you are running at >1000 fps with the above problem, the eye can detect glitches and twitches in the movement onscreen. At 1100fps, your timer based movement could be up to 10% in error.

Am I the only one using timer based movement with > 1000 fps?

As a work around, I provide an option for the player to set VSYNC mode and hardcode the timer based movement multiplier to 1.0 which will suffice for now.

Paul Johnston
TGC Developer
22
Years of Service
User Offline
Joined: 16th Nov 2002
Location: United Kingdom
Posted: 27th May 2014 17:00
Quote: "I posted about this in this thread, as I found that I had a -1.#IND00 value breaking my timer."


In that thread you mention that MasterTimer.Adjust# could be equal to 0.0, how was it calculated?
Digital Awakening
AGK Developer
22
Years of Service
User Offline
Joined: 27th Aug 2002
Location: Sweden
Posted: 27th May 2014 19:02
I have RTA running at near 4000 FPS windowed and around 2500 FPS fullscreen on my gaming PC. It's silky smooth on both. And I can detect every little bump. I use getframetime() (stored to a global variable) to control everything in the game. Make sure that everything concerning positioning uses floats.

I also have coded in the option to limit FPS to 60 or 120, or to use v-sync. So players can try what feels best to them.

nz0
AGK Developer
17
Years of Service
User Offline
Joined: 13th Jun 2007
Location: Cheshire,UK
Posted: 27th May 2014 20:13
This is the timer routine I am using. I put the 0.0 handler in there to handle the adjustment.



Paul Johnston
TGC Developer
22
Years of Service
User Offline
Joined: 16th Nov 2002
Location: United Kingdom
Posted: 27th May 2014 21:59
Try using Timer() or GetFrameTime() instead of GetMilliseconds()
baxslash
Valued Member
Bronze Codemaster
17
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 28th May 2014 15:41
Yes, GetMilliseconds and even Timer will not be as accurate as GetFrameTime. Timer will keep getting bigger and less accurate whereas GetFrameTime is always as accurate as you are likely to get.
nz0
AGK Developer
17
Years of Service
User Offline
Joined: 13th Jun 2007
Location: Cheshire,UK
Posted: 30th May 2014 17:40
Well, GetFrameTime() is a better and it is simpler to implement.

I still notice a small blip when scrolling which is about every 1 second but can't work out where that's coming from.
I captured 5 seconds of GetFrameTime() values and logged them out at exit and didn't spot any variations which would cause this.

Changing back to using GetMilliseconds() temporarily, showed that the 1 second blip still occurs, so I'm stumped as to where that's coming from.

Van B
Moderator
22
Years of Service
User Offline
Joined: 8th Oct 2002
Location: Sunnyvale
Posted: 30th May 2014 18:02
I wonder if that 1 second blip is actually something else. Like, if you have any Razer hardware, that comes with a lot of rubbish software these days... like that game scanner that needs 1/4 of a processor the whole time for some reason.

Maybe it's worth trying a gradual change to the timer, like:

nt#=GetFrameTime()
if Elapsed#<nt# then Elapsed#=Elapsed#+0.001
if Elapsed#>nt# then Elapsed#=Elapsed#-0.001

Just guessing here - but if you change the 0.001 part to a suitable value, and use Elapsed#, maybe it'll help to hide the sharp changes in frame time - so if there is a delay somewhere it won't necessarily get a chance to affect things, because the actual Elapsed# value is gradually changed to suit GetFrameTime()
With some refinement and some time to ramp up (or a workaround to allow sharp changes at the start) it might make a difference.

One other thing to look at is your sound files - maybe there's a big awkward sound file that has to be buffered or something before being played. I'd work backwards, disabling things until the delay jump disappears - I have seen similar things with my last AppGameKit project, these days I just try to stick with fixed frame rates.

I am the one who knocks...
nz0
AGK Developer
17
Years of Service
User Offline
Joined: 13th Jun 2007
Location: Cheshire,UK
Posted: 30th May 2014 18:58
Thanks. I will look at the sound thing, as there is a large looping background sound.

Personally, I would prefer to use fixed timings and have offered an option to switch to vsync in this game. I suppose it all depends on the game and target platform (damn those mediocre laptop users!)

Login to post a reply

Server time is: 2024-11-25 05:10:13
Your offset time is: 2024-11-25 05:10:13