Facebook
From ArtinTheCoder, 8 Months ago, written in Python.
Embed
Download Paste or View Raw
Hits: 216
  1. extends CanvasLayer
  2.  
  3. var time = Global.speedrun_time
  4.  
  5. func _physics_process(delta):
  6.  time = float(time) + delta
  7.  Global.final_speedrun_time = time
  8.  update_ui()
  9.  
  10. func update_ui():
  11.  # Calculate minutes and seconds
  12.  var total_seconds = int(time)
  13.  var minutes = total_seconds / 60
  14.  var seconds = total_seconds % 60
  15.  
  16.  # Format minutes and seconds with leading zeroes if necessary
  17.  var formatted_time = str(minutes) + " min " + str(seconds).pad_zeros(2) + " sec"
  18.  
  19.  Global.speedrun_time = formatted_time
  20.  
  21.  $Label.text = formatted_time
  22.