i have wrote a time counter function to display time on window but i i want help to right it in cleaner form
Text Menu::returnTime(Clock clock)
{
//to set time variable to the elapsed time
time = clock.getElapsedTime();
//set the int seconds to elapsed time - 60 if minutes have passed
//bec elapsed after 1 minute doesnt reset will be 61 seconds
seconds = time.asSeconds()- 60 * minutes;
//if seconds less than 10 draw extra 0 so it look like time: 0:00 not time : 0: 0
if (seconds < 10)
str = "Time: " + to_string(minutes) + ":" + "0" + to_string(seconds);
else
str = "Time: " + to_string(minutes) + ":" + to_string(seconds); //else set it normaly cast variables to strings
if (seconds == 60)
minutes++;
//set the text string to next time string
timeText.setString(str);
return timeText;
}
and also how i can do reset clock if seconds = 60
Can you rephrase the question, as I'm unsure what you're trying to achieve exactly?
i want to know how to reset the clock after it hit 60 seconds so i can get rid off this line
//set the int seconds to elapsed time - 60 if minutes have passed
//bec elapsed after 1 minute doesnt reset will be 61 seconds
seconds = time.asSeconds()- 60 * minutes;