Eli Delventhal
|
 |
«
Reply #30 - Posted
2012-03-05 22:49:19 » |
|
It works in any circumstance. All drawing is one frame behind so that you can interpolate everything.
|
|
|
|
ra4king
|
 |
«
Reply #31 - Posted
2012-03-05 23:35:29 » |
|
Wut?
|
|
|
|
sproingie
|
 |
«
Reply #32 - Posted
2012-03-05 23:37:33 » |
|
Welcome to page 2, ra4king.
I really don't know why we even have article format.
|
|
|
|
Games published by our own members! Check 'em out!
|
|
ra4king
|
 |
«
Reply #33 - Posted
2012-03-05 23:43:25 » |
|
O___O I didn't notice that this was page two! I thought this a whole new article by some random n00b 
|
|
|
|
ManIkWeet
Senior Newbie 
|
 |
«
Reply #34 - Posted
2012-03-06 09:49:35 » |
|
If all drawing is one frame behind, don't you notice input lag?
|
|
|
|
Roquen
|
 |
«
Reply #35 - Posted
2012-03-06 14:39:38 » |
|
I've only done a quick skim, but don't use floating point for digital counters.
|
|
|
|
Eli Delventhal
|
 |
«
Reply #36 - Posted
2012-03-06 21:41:48 » |
|
Which counter are you referring to? If it's the timer then it doesn't matter, any precision lost will be so minute.
|
|
|
|
ManIkWeet
Senior Newbie 
|
 |
«
Reply #37 - Posted
2012-03-07 20:02:14 » |
|
I have a new issue with the fixed timestep, it seems that for alot of computers the game is very choppy (game herz 30 with 60 fps)... This happens on my desktop very rarely and I have a hard time finding the fix, anyone knowing about this?
|
|
|
|
Eli Delventhal
|
 |
«
Reply #38 - Posted
2012-03-07 22:01:54 » |
|
Remove the Thread.sleep() call in there, and use Thread.yield() only.
|
|
|
|
ManIkWeet
Senior Newbie 
|
 |
«
Reply #39 - Posted
2012-03-08 17:32:32 » |
|
Didn't work, the weird thing is that when I print on render and tick, the output is: tick render render tick render render tick...
So it should work, maybe there's a problem calculating the interpolation?
|
|
|
|
Games published by our own members! Check 'em out!
|
|
ManIkWeet
Senior Newbie 
|
 |
«
Reply #40 - Posted
2012-03-08 19:42:42 » |
|
This forums has serious issues with the EDIT button...
It's not the interpolation either
|
|
|
|
Roquen
|
 |
«
Reply #41 - Posted
2012-03-09 15:22:23 » |
|
If it's the timer then it doesn't matter, any precision lost will be so minute.
Actually it can be very significant. The lines I'm talking about are ones like these: 1
| double X = System.nanoTime(); |
Which when the counter get big will start to drop least sig bits (up to 11) of the input, which are the most important and keeps the high bits, which we don't really care about.
|
|
|
|
ManIkWeet
Senior Newbie 
|
 |
«
Reply #42 - Posted
2012-03-11 12:14:14 » |
|
New update: when I unlimit the FPS, I still get choppy spikes, which means there's some sort of inprecision in the tick management... Please investigate 
|
|
|
|
ManIkWeet
Senior Newbie 
|
 |
«
Reply #43 - Posted
2012-03-11 15:37:33 » |
|
OR there's something wrong with canvas/bufferedstrategy... OR interpolation still, but when printing that I see no differences
|
|
|
|
Roquen
|
 |
«
Reply #44 - Posted
2012-03-11 15:42:12 » |
|
If you're printing all the time..well that takes forever in nanotime.
(EDIT) Unless your rendering the text yourself. (not some outputstream kinda thing)
|
|
|
|
ManIkWeet
Senior Newbie 
|
 |
«
Reply #45 - Posted
2012-03-12 19:47:31 » |
|
first calculating the interpolation, then System.out it
|
|
|
|
Eli Delventhal
|
 |
«
Reply #46 - Posted
2012-05-11 17:59:27 » |
|
I added a pause button to the fixed timestep so you can test out catch-up behavior, and I also fixed a bug there (thanks roland for pointing it out) where the catchup was being calculated incorrectly.
|
|
|
|
wolfcall
Junior Newbie
|
 |
«
Reply #47 - Posted
2012-06-02 02:47:07 » |
|
I just wanted to say thanks this is exactly what I needed for a project of mine. 
|
|
|
|
|
Roquen
|
 |
«
Reply #49 - Posted
2012-06-02 11:30:18 » |
|
I'm not sure if this is the failure in question...but I know that one problem early versions had was that the programmer didn't understand that 1/10 of a second (the logic rate it ran at) isn't a representable number.
|
|
|
|
wolfcall
Junior Newbie
|
 |
«
Reply #50 - Posted
2012-06-02 21:36:00 » |
|
I should say thanks again because this also fixed a second problem I didn't get to fix yet. so thanks twice over 
|
|
|
|
Eli Delventhal
|
 |
«
Reply #51 - Posted
2012-06-03 00:30:57 » |
|
Nope, Danny, I think you're wrong. You're not keeping a running total added, you're keeping a total that is refreshed multiple times per second. So any lost precision is going to be completely impossible to notice. If you were adding the time every single frame to store the game time or something, I could see that being an issue. But in this case, no.
|
|
|
|
Roquen
|
 |
«
Reply #52 - Posted
2012-06-03 10:30:21 » |
|
You're both right in the context you're talking about.
|
|
|
|
The Cure
Senior Newbie 
|
 |
«
Reply #53 - Posted
2012-07-31 17:29:57 » |
|
So I noticed when I added 15 instead of 10 to the sleep on the variable timestep, it didn't error out on me. Did it error out on anyone else?
The error was that the time to sleep was a negative value, but it look like it's only for the first time the loop runs. Every time after that it's between 8 and 10. Any ideas? I think i solved that error just adding Math.abs(); to the Thread.sleep calculation (making the result be always positive): 1
| Thread.sleep(Math.abs(lastLoopTime - System.nanoTime()) / 1000000 + 10); |
For now i didn't have any problems, but i really don't know if my solution is the correct one, and if it affects the logic behind the variable timestep loop. Maybe someone could tell me if i'm doing something stupid...
|
"A candle loses nothing by lighting another candle" - Erin Majors
|
|
|
ra4king
|
 |
«
Reply #54 - Posted
2012-07-31 17:44:25 » |
|
That's because it's supposed to be the other way around: System.nanoTime() - lastLoopTime. No need for Math.abs 
|
|
|
|
Eli Delventhal
|
 |
«
Reply #55 - Posted
2012-08-04 01:13:20 » |
|
I don't think so. You're trying to wait for 10ms, and if the last loop time was slower than that you wait for less time. See Kev explain below. From Kev's (since update) tutorial: To do this we're going to want each cycle round the game loop to take exactly 10 milliseconds. We know at what time the cycle started (lastLoopTime) and we know what time it is now, so with a small amount of maths we can sleep for the right amount of time like this: 1 2 3 4 5
|
SystemTimer.sleep(lastLoopTime+10-SystemTimer.getTime());
|
Note: GAGE Timer actually supports a "sleepUntil()" method that could be used here. However, since the SystemTimer is trying to allow us to change between timing mechanisms we should try to rely on simply sleeping for the right amount of time. The only difference is the division, that's because we're using nanoTime here and Kev is only using ms.
|
|
|
|
Eli Delventhal
|
 |
«
Reply #56 - Posted
2012-08-04 01:17:32 » |
|
Although actually the +10 should be there if we were shooting for 100 fps, and we're going for 60. I should change that to 16.
|
|
|
|
SHC
|
 |
«
Reply #57 - Posted
2012-11-03 01:26:55 » |
|
Could you please say me what's GAME_HERTZ? Is it the required number of updates per second?
|
|
|
|
Eli Delventhal
|
 |
«
Reply #58 - Posted
2012-11-03 05:15:08 » |
|
Correct. It's like FPS but in game updates, not frame updates.
|
|
|
|
KittenKoder
|
 |
«
Reply #59 - Posted
2012-11-03 05:35:57 » |
|
I can't believe your "bad" examples, I actually see people using them in full games as well. You'd think that with all the information out there which says "don't do it" or the throttling of your CPU would be enough. lol
I hope more people find this thread.
|
I am no one else.
|
|
|
|