Jump to content
  • Advertisement
Sign in to follow this  
  • entries
  • comments
  • views

I hate working with old code

Sign in to follow this  


(also rambling!)

So one of the big things I've had to do with VC is make it framerate-independent. Partially to avoid 60Hz tearing if possible. The tearing at ~60FPS is EXTEREMLY noticible on my laptop. It's bad at other rates, but 60 is evil.

Now normally, you can take a game, like UT or Quake 3 or whatever, and it DOES indeed have tearing (hit an arrow key to turn in quake 3 and you'll see tearing at 60, or 90, or whatever).

For VC, it's a very high-contrast game, and uses a LOT of vertical lines and shapes. So tearing is visible almost anywhere.

The smoothest appearance
- when the framerate is unlimited and can draw whenever it wants
- at 60 FPS it appears really smooth until the tearing every half second or so. (actually this can depend on the vsync setting...)
So for the most part I've addressed these issues.


I still have some really really old (2004, 2005) disgusting code which is really framerate dependent. Usually involving movement which uses what is essentially exponential growth and decay, e.g.

update {
x += (destX - x) / 10;

This produces a nice slow-down effect, like when you see bullet-time activated.
I've made some efforts to write exponential function evaluators to fix most code that appears like that, but some code I wrote was a little more complicated.

What's also interesting is that functions like these seem to produce weird jittering effects IF you don't [update and then draw] ONCE every 16.66666666 ms.
There's all sorts of explanations for this, but I don't want to think about it.

Such as the camera-gliding effect you see in the VC menu. It used this fancy acceleration thing and I remember I used some weird math to come up with some of this.

The picture below shows me using different attempts to re-do it.

Eventually I decided to see if I could just do render-time interpolation of the values produced in the update:

This looks nice. Perfect :D. Aaaand a screenshot of the game, because I'm so happy about this!

The lesson here, kids, is always write your game to be framerate independent. You can have your game logic run at weird fractional amounts but at least what the user sees will always be as smooth as possible.
Sign in to follow this  


Recommended Comments

There are no comments to display.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!