Jump to content


Member Since 06 Jul 2013
Offline Last Active Apr 04 2016 05:07 PM

Posts I've Made

In Topic: Trouble making my animation smooth

30 July 2013 - 04:08 PM

If you measure the framerate once a second, and base your timing off that it's not accurate and certainly not frame rate independent.


I get the current time at the start of each frame and use it for doing the physics. The FPS counter is completely seperate so I don't think it has an effect on the physics.


Well, getting away from caring about framerate beyond vsync is a good thing, in my opinion. I'm glad you got that out of the way early.


When trying to figure out how to use vsync in SDL, I was told that vsync doesn't work in windowed mode since the draws are managed by the OS. If I modify the program to use SFML instead of Allegro, vsync doesn't work and the animation is not smooth so I feel that using Allegro's vsync is kind of cheating and not an actual solution (since if I decide to switch to SDL and SFML the problem will show up again).


It sounds like your smoothness issue might have been from having different amounts of progress between each vsync.


Yes, that's what I'm thinking as well so I'll try and figure out if there is a way to solve this.

In Topic: Trouble making my animation smooth

30 July 2013 - 10:52 AM

Sorry, I tried recording the bug but it introduced extra lag and the actual issue wasn't clearly visible in the video. Changing step duration to 2.0 makes the animation very slow and it's a little bit smoother.


I may have discovered the issue: after swapping the buffers, I started printing the time difference between the swap that just happened and the previous swap. It normally prints 0.008s and 0.009s but 0.01s are quite frequent so maybe this is causing the animation to not look as smooth? I found out that Allegro has vsync option and enabling that made the animation very smooth. From the output, I got 0.016s with occasional 0.0017s which is a lot more even.

In Topic: Trouble making my animation smooth

29 July 2013 - 01:03 PM

My framerate varied between 58 and 62 and I was told on the Allegro forum that this is normal and I should  calculate the average instead. When playing games, I notice that the FPS changes a lot and so I assumed that games still look smooth even if the FPS isn't completely steady.


And... I thought I was already using frame rate independent timing? :(

In Topic: Trouble making my animation smooth

28 July 2013 - 11:52 PM

Using the alpha to render is the whole point of doing the loop this way. Try "new_pos_x += velocity_x * delta_time;" in the inner loop. See if anything changes.


delta_time is in seconds and it's usually about 0.00-something so making that change just makes the circle stay still. Changing the type of the position variables to double makes the circle move ever so slightly.

In Topic: Trouble making my animation smooth

28 July 2013 - 09:29 PM

Thank you for the suggestion. Just tried that and it made no difference. With the pause, my frame rate is around 125 so the physics is updated once for every 2 to 3 renders.