Time Control
A quick note about time control, with code.
XNA makes time relatively simple - a GameTime object is managed automatically and given to you every frame. This makes calculations involving time relatively simple. However, what happens when you want to slow down time?
You could just use a variable to set the time speed, and then multiply your elapsed time by that every frame. However, if you try this trick on total times, you better not change the time speed, because your numbers will be way off when you change speeds.
My team ran into this problem on our DBP project, and I suggested that we use a time controller to manage game time. Basically, the time controller maintains its own time variables, which it updates every frame based on the current time speed (adding to total modified time every frame). Then, when updating objects, the time controller’s time is used (be it real or modified time).
You can download the code below - it’s part of a library I’ve been working on for my own projects, but since it seems like it’d be useful to others, I figured I’d post it. Let me know if you find it useful.
ps: I’m obviously not dead - just been really busy lately…hopefully will be able to share what I’m working on in a couple weeks.
August 1st, 2007 at 6:29 pm
Nice to see you around
I can’t wait to see what you’ve been up to.