0 votes

hello i wish to calculate hrs through delta time for a speedrunuing game im making
but idk how to calculate it
code:

func _process(delta):
time += delta

var mils = fmod(time,1) * 1000
var secs = fmod(time,60)
var mins = fmod(time,60*60)/60
if mins >= 59:
    hr += 1
    mins = 0

time_passage = String( "%02d : %02d : %02d : %04d" % [hr, mins, secs, mils] )
in Engine by (12 points)

1 Answer

0 votes
if mins >= 59:
    hr += 1
    mins = 0

doesn't quite make sense... because mins is the remainder of when you divide the time in seconds by 60.
what you want is something like:
hr = floor(time / 60 / 60)
instead of those 3 lines

by (1,342 points)
Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.