So far, our Silverlight game does not handle the elapsed time between each rendered frame. We need this information in order to create animations that consider time as a variable.
We are going to create a new abstract superclass to add time management capabilities to the basic Game
(Balder.Core.Game
) class provided by Balder:
1. Stay in the
3DInvadersSilverlight
project.2. Create a new class—RealTimeGame (a subclass of
Game)—
using the following declaration:public abstract class RealTimeGame : Game
3. Add the following line of code at the beginning (as we are inheriting from Balder's
Game
class):using Balder.Core;
4. Add the following
private
variables and one property to handle the ticks and the elapsed time between each rendered frame:// Holds the time when the method finished rendering a frame protected DateTime _lastTick; // Holds the elapsed time after the last call to the Update method protected...