Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm wanting to add a timer in an XNA game using C#. The ultimate goal is to increment a score in a game every second by 10 points. As of now the score stays at zero. Watching YouTube videos is proving to be counter productive as they're quite confusing.


share|improve this question
Show code of what you have tried up to now. – Jon May 3 '13 at 14:41

I believe something like this should work. (Place the code in the Update block)

Timer += gameTime.ElapsedGameTime.TotalMilliseconds; // Increment the timer by the elapsed game time.

if (Timer >= 1000) // Check to see if one second has passed.
    Points += 10; // Increment the points by 10.
    Timer -= 1000; // Reset the timer.
share|improve this answer
Note that Timer is a number, not an instance of special class. – John McDonald May 3 '13 at 19:03

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.