Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8888951
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T22:08:35+00:00 2026-06-14T22:08:35+00:00

I am trying to make a timer in C#. I do this by counting

  • 0

I am trying to make a timer in C#. I do this by counting frames then making a variable(seconds) that is equal to the number of frames divided by 60. I also count minutes by having another variable(minutes) that is equal to seconds divided by 60.

The problem
When minutes is upped by one, seconds keeps counting and i am not sure how to fix this. I want to add one to minutes whenever seconds reaches 60 but then go back down to zero without seting minutes to zero.

Here is what I’ve tried:

    int frames = 0;
    int seconds = 0;
    int minutes = 0;

This is in update:

    protected override void Update(GameTime gameTime)
    {

        minutes = seconds / 60;

        seconds = frames / 60;

        frames += 1;
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T22:08:36+00:00Added an answer on June 14, 2026 at 10:08 pm

    I would suggest you just count frames, and derive seconds and minutes from that, whenever you need to. So if you really need to update all the variables in each Update call, you’d have:

    frames++;
    seconds = (frames / 60) % 60;
    minutes = frames / (60 * 60);
    

    Or to be clearer, define some constants:

    const int FramesPerSecond = 60;
    const int SecondsPerMinute = 60;
    const int FramesPerMinute = FramesPerSecond * SecondsPerMinute;

    …

    frames++;
    seconds = (frames / FramesPerSecond) % SecondsPerMinute;
    minutes = frames / FramesPerMinute;
    

    (If you need to reset minutes to 0 after an hour, you would need to extend this further.)

    It’s not clear what you’re trying to do though – there may well be a better way of achieving it. If you’re definitely trying to count frames, this is fine… but if you’re trying to compute elapsed time, you should remember a base time and then subtract that from the current time, rather than relying on a timer firing exactly once per second.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to make a timer count down from 5 seconds to zero before
I am trying to make a timer for my game that counts down from
I'm trying to make a timer that measures the execution time of a scope.
Im trying to make a small app in c++ that saves midifiles with this
I'm trying to make a jQuery plugin that executes a method on a timer.
I created a game with timer, I am trying to make that when the
I'm using Flex 3 with Flash 9. I'm trying to make a timer that
I'm trying to make an application that runs an animation. To do this I've
Im trying to make a timer that counts down from 30 to 0 but
I am trying to make a timer and I want a circle that is

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.