The big TimeDelta headache

For questions about using Classic.

Post » Sun Nov 02, 2008 11:00 pm

I've thought about this idea and it's interesting... one thing I'm sure of, is that the logic rate should never be less than the display rate. If this happens, eventually you end up drawing the screen with no logic runs in between, which results in an uneven display. Your example uses 60 - my refresh rate is 75 Hz so this would be happening for me. I noticed the scrolling seemed to be jittering side to side constantly, maybe that's a side effect of that.

Next problem is that you might get uneven logic runs - alternating 1 and 2 logic runs per display means you'd move twice as far in one display than the next - but I guess we can live with that, since everything is pixel perfect precision. V-synced display is not perfect in windowed mode - it's much more reliable in fullscreen - so V-synced windowed games tend to 'drop' a frame (ie. miss a V-sync) every now and then. This could explain the logic running a lot to catch up when the next tick runs.

So it's a nice way to go about coding things - the only catch is if this is to be built in to the runtime, it can't distinguish movement code so would have to run the entire event list every logic execution. This might be OK I guess, but it might also use a lot of unecessary CPU. I would prefer to avoid using a trigger like 'On logic execution', because it won't integrate nicely with other features (ie. in theory it should be able to easily switch between a timedelta'd platform engine to a fixed rate logic platform engine without recoding the whole thing). If a 'fixed rate logic' mode was enabled, combined with 'override timedelta' (so timedelta is constant), this would achieve a similar thing, but at the expense of running the entire event list.

Your engine looks pretty good at the moment - you might find it more convenient to simply put all the movement code as a subevent to a single trigger (saves repeating the condition all the time). Also, the Function object does what you're trying to do with fastloops (a one-run fastloop is effectively a function). And as mentioned, you probably want to boost this to at least 120fps logic.

So really for a pixel-perfect engine which is as efficient as possible, you've hit on the right way to do it already! It can be done entirely with events. Do you think it should still be a built in feature, at the expense of running the entire event list?
Scirra Founder
B
359
S
214
G
72
Posts: 22,948
Reputation: 178,532

Post » Sun Nov 02, 2008 11:36 pm

Yeah I just boosted the rate to 120 not too long ago and adjusted the all the values to match the speed. It works pretty nicely I'd say. Yeah, the uneven movement is there but it seems mostly unnoticeable, but it is a flaw. Granted if you run at higher logic rates which I think a lot of games could easily get away with (IWBTG for example which has a very simple engine), the difference would be very hard to notice. at all

But yeah at this point I don't think a built in feature is really a necessity. I think this is actually better in a way as it's more customizable and easy for me to select what needs to be time sensitive and what doesn't.I would perhaps want features that would facilitate precision games such as manual animation 'tick' advancement, which could be useful elsewhere too, but I think this is rather low priority. I'll try and make a simpler 'tutorial' example with comments and maybe write a small tutorial so people who are in situations like me or the original poster won't have to bug the crap out of you.

:P I'm just happy I don't have to annoy the hell out of you about this anymore. Thanks for your advice and patience through all my bitching and long winded posts.

(I'll also look into the function thing. This is as good a time as any to restructure my engine a bit and clean things up)
B
12
S
4
G
4
Posts: 238
Reputation: 2,426

Post » Mon Nov 03, 2008 3:54 am

[quote="kayin":3gimrn8f]:P I'm just happy I don't have to annoy the hell out of you about this anymore. Thanks for your advice and patience through all my bitching and long winded posts.[/quote:3gimrn8f]

Does this mean no more walls of text between you and Ashley any more? This is truly the end of an era :P

Glad to see you have come to a resolution though :)
Moderator
B
5
S
2
G
6
Posts: 4,348
Reputation: 10,971

Post » Mon Nov 03, 2008 5:05 am

[quote="deadeye":1dodidvi][quote="kayin":1dodidvi]:P I'm just happy I don't have to annoy the hell out of you about this anymore. Thanks for your advice and patience through all my bitching and long winded posts.[/quote:1dodidvi]

Does this mean no more walls of text between you and Ashley any more? This is truly the end of an era :P

Glad to see you have come to a resolution though :)[/quote:1dodidvi]

Hahaha, I certainly had a "lol" at that one. A friend of mine frequently joked "Hows your novel coming along?" if he was over while I was making a post on the issue (or occasionally some other issues elsewhere :P). But yeah, I don't think we're going to come across an issue that required this level of headbanging.

I'm just glad everyone gets to be happy in the end and that the solution is extremely elegant in implementation and it didn't require Ashley to use up his valuable time. I'll be writing up a tutorial for this (and maybe other time delta issues/solutions) in the future. Hopefully this won't have to come up again -- and if it does, hopefully it'll be a much smaller issue.

It'll be sad without having anything to rant about. :(
B
12
S
4
G
4
Posts: 238
Reputation: 2,426

Post » Mon Nov 03, 2008 5:13 am

[quote="kayin":38k3xxb3]It'll be sad without having anything to rant about. :([/quote:38k3xxb3]

Try this:
[quote:38k3xxb3]Were all going to die, you know that dont you? One of these days, probably during Friday rush hour, theres going to be a 9.9 Earth quake and then its all going to come down. No more Taco Bells, no more Rite-Aid, no more little oompah-loompahs making chocolate for Willy Wonka. Itll all be over.

At first I thought that this would be kinda cool. You know, puts me on an even footing with the BMWs and the cool people. When society breaks down, people like me with street smarts, who graduated from the school of hard knocks the lower to middle class people will inherit the earth - survival of the thickest. Just think: people freak out when their toilet doesnt flush right or they cant login to Live Journal. Whats gonna happen when Starbucks runs out of coffee? Maximum anarchy.

Anyone who lived through the Los Angeles riots knows what I mean. Back in 1992, we were all appalled at the looting and burning but we could all console ourselves that in a couple days it would all be over. No such luck come doomsday and no one, including myself, has made any provisions or taken any precautions to prepare for this Apocalypse. When the big one happens, Ill be fucked just like everyone else. Ill have to recycle my feces to power my car and start eating veggies and tree bark. It will be a real horror show living day to day no more Kurt Russels, no MTV, no more fear of aids in other words, normal.

This service announcement has been brought to you by the letters and numbers OU812 thank you please drive through[/quote:38k3xxb3]

~Sol
Tired of crappy file hosts that are crappy? Get DROPBOX - https://db.tt/uwjysXJF
Moderator
B
45
S
17
G
37
Posts: 2,853
Reputation: 25,966

Post » Mon Nov 03, 2008 12:29 pm

Wow that's just great Kayin! :D :D :D

Just had to add 2 events to my exisiting engine and make the whole movement stuff subevents. And that's it, works just fine!

I think my very own TimeDelta headache may be finally gone now. Thx a lot! :mrgreen:
B
21
S
6
G
10
Posts: 1,024
Reputation: 7,445

Post » Mon Nov 03, 2008 9:33 pm

No problem! Believe me, I'm thanking my self too! This has been a big headache for me. Now its time to put together some more examples.
B
12
S
4
G
4
Posts: 238
Reputation: 2,426

Post » Tue Nov 04, 2008 12:16 am

i dont feel like using the delta!!!!!!!
im against the man

no kidding ashley, im just lazy to insert that thingy everywhere

edit:well i actually read your post now and i must say, you are alot like me, anal wise lol. i too try really hard to get things perfect, always thinking it should run perfectly how i invisioned it, and never do something i didnt intend, but after a while you realise that everything doesnt have to be perfect, infact every shouldnt be perfect or else youll spend way to much time trying to keep things perfect while you should be working on the game. games arent good because they have beautiful programming, i cry because of this but its the truth, just like how animators in 3d movies get no props, yet the actors who voice a character get emmys or wtv ugh
you gotta realise that good games are good cause their fun, not cause everthings perfect, world of goo is super fun, but it has lotsa problems and things i would never let fly, but the thing is, thats not what makes it bad or good. a slight animation bump and things like that are annonying to us, but to a player they dont really care, its only the experience which is returned to them which matters. i love over complicating things so their perfect but it always ends up making something fruitless cause it takes to long. i do like how you made this problem simple tho, i would like to see a tut
B
52
S
7
G
6
Posts: 1,945
Reputation: 7,610

Post » Sun Feb 22, 2009 11:01 pm

I know this is old but I DO have something to contribute.

In YEARS of discussing this bit (sometimes heatedly) with fellow coders, I found out that the best thing to have is:

-fixed logic rate, to gauge minimum object size and max speed, thus making sure no object will ever go RIGHT THROUGH another.
-decoupled vsynched graphic updates, for maximum smoothness
-interpolated animation: this is key. Without this, you better couple logic with the graphics update rate or it'll look strangely jerky.

But you all knew this. Now comes my contribution:
I also spent a long time fighting timer issues, because the timer I was using (SDL) has a really crappy resolution (10ms!!)

So with that low low resolution, animations and general game logic used to jump around a lot. First approach was to average over a number of frames, then the game would go smoothly over that number of frames and then jump to the new framerate, so that's no good either.


The next approach is really good and gave me solid animation with a crappy timer:
-Keep a circular buffer, save the the timedelta in a new cell and move the head in each update, average all stored timedeltas and return that.
TADA! high-precision non-jumping timer feeding from any timer, crappy or not. That added to the (already in Construct) minimum FPS makes for a SOLID and smooth logic.

Suggestion? Could specify the size of this circular array in application properties :) Larger takes longer to adapt to FPS changes, smaller could be jerkier. I kept using 10 to 20 cells and that was enough (remember, I had 10ms resolution!).
B
3
S
2
G
4
Posts: 1,445
Reputation: 4,665

Post » Sun Feb 22, 2009 11:14 pm

There's always QueryPerformanceCounter, which is accurate to microseconds, and available to any C++ program. Construct uses it.
Scirra Founder
B
359
S
214
G
72
Posts: 22,948
Reputation: 178,532

PreviousNext

Return to Help & Support using Construct Classic

Who is online

Users browsing this forum: No registered users and 3 guests