C
Cupid Stunt
Guest
I'm creating a clock for my game and I'm having issues with zero padding the numbers.
I could use if statements and I will if necessary, but that's ugly code.
In python I'd simply use:
My output would be: 01:24 or 03:07 or 12:05
The point is to add the extra zero into the string when it's needed to make the number always have 2 digits.
My current code is:
This works well, but does not ensure that each number is 2 digits.
I could use if statements and I will if necessary, but that's ugly code.
In python I'd simply use:
Code:
'{:02d}:{:02d}'.format(minutes, seconds)
The point is to add the extra zero into the string when it's needed to make the number always have 2 digits.
My current code is:
Code:
draw_text(20,20, "Time: " + string(minutes) + ":" + string(seconds));