No Description
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

scoreUI.gd 757B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. extends Control
  2. onready var label : Label = $MarginContainer/Label
  3. var game_mode
  4. var max_time = 30
  5. func _ready():
  6. Signals.connect("update_score",self,"update_score")
  7. func update_score(score: int):
  8. label.text = String(score)
  9. func start(mode: String):
  10. match mode:
  11. "score":
  12. update_score(0)
  13. show()
  14. "time":
  15. update_score(max_time)
  16. show()
  17. var t = Timer.new()
  18. t.set_wait_time(1)
  19. add_child(t)
  20. t.start()
  21. for n in range(max_time,0,-1):
  22. update_score(n)
  23. yield(t,"timeout")
  24. update_score(0)
  25. Signals.emit_signal("win")
  26. _:
  27. print("game_mode not recognized by scoreUI")
  28. func set_max_time(time: int):
  29. max_time = time
  30. func init(mode, goal: int):
  31. game_mode = mode
  32. if (goal != 0):
  33. max_time = goal
  34. hide()