Weird DeWitter's Game Loop Problem

Started by
12 comments, last by handoman 11 years, 2 months ago

So I've been searching and studying up on game loops and decided to go with deWitter's(the final version with interpolation). Yesterday I implemented the loop into a simple test game to see how it works, and it worked fine. My little circle would move across the screen very smoothly with no problems at all, so I saved everything and took a break.

Okay.. now here's the problem: I came back later to check it out again, but this time there was a slight stutter when the circle moved! I had no other winndows open, only CodeBlocks and the program, but when i first successfully tried it, I had Chrome open. so I tried it again with chrome open, and it didn't stutter! but when I try it with nothing open, there's that small stutter again. I looked at the code over and over, and it was exactly like the code from the (site), so I am positive it is not a problem with my code.

It's very confusing because it Really does work fine,the small stutter is very subtle, but it is there. I am using SFML 2, so maybe there is a problem with the clock function? What do you guys think? Is this even a programming problem or just my pc?

Advertisement

Have you tried building your program in release mode, and executing without having other things open?

I've never used SFML, but if it doesn't work properly based on the programs you have open, then i don't see how that might be a programming issue.

Yes, there is a problem with clock() and it should never be used.

On Windows®, always use QueryPerformanceCounter() and QueryPerformanceFrequency(). The resolution of clock() is low and its problems with games/high-performance timing can be found via Google.

This is most likely your main problem, but I have listed many other potential problems here: Fixed-Time-Step Implementation

You will want to give it the once-over and be sure you are not making some of the common mistakes people often make when first implementing fixed time-steps.

L. Spiro

I restore Nintendo 64 video-game OST’s into HD! https://www.youtube.com/channel/UCCtX_wedtZ5BoyQBXEhnVZw/playlists?view=1&sort=lad&flow=grid

Chrome is so powerful that it speeds up other programs while it's running.

Well played, Google... Well played...

biggrin.png

void hurrrrrrrr() {__asm sub [ebp+4],5;}

There are ten kinds of people in this world: those who understand binary and those who don't.

I know right? it should go slower with other stuff open not the other way around. I've been looking up on better time keeping methods instead of sf::clock, I avoided the QueryPerformanceCounter, since it only works on windows. but I guess cross platform isnt really necessary for me, so I'll look into it.

If you are using C++11, you can use the new standard and cross-platform high resolution timers in that.

See std::chrono::high_resolution_clock::now()

yea! I was just looking at that. But i guess my compiler doesnt support 11 yet? hmmm...I thought it was up to date.

yea! I was just looking at that. But i guess my compiler doesnt support 11 yet? hmmm...I thought it was up to date.

What compiler? GCC/MinGW supports (most of) C++11 if you pass -std=c++11 to the compiler (earlier versions use -std=c++0x).

yea, I got c++11 to work. I guess code::blocks just doesnt recognize some of the classes( it doesnt highlight them or anything), but they still work

cool so I got the chrono classes to work and convert my game loop to use the high resolution clock insted of sf clock, and it works but it still looks smoother while Chrome is open!! haha it seems so odd to me.

This topic is closed to new replies.

Advertisement