1
0

title.gd 790 B

123456789101112131415161718192021222324252627
  1. extends Node2D
  2. ## Title screen: a big core with balls bouncing around it, and the saved level.
  3. const BALL_SCENE := preload("res://scenes/ball.tscn")
  4. var _level := 0
  5. func _ready() -> void:
  6. var screen := get_viewport_rect().size
  7. $Core.position = Vector2(screen.x / 2.0, screen.y * 0.25)
  8. for i in 10:
  9. var ball: Ball = BALL_SCENE.instantiate()
  10. ball.position = Vector2(screen.x / 2.0, screen.y - Params.BALL_RADIUS * 2.0)
  11. $Balls.add_child(ball)
  12. ball.throw()
  13. var progress := Progress.load_level()
  14. _level = progress[0]
  15. if _level != 0:
  16. $UI/LevelInfo.text = Params.MSG_LEVEL_BACK % [_level, progress[1]]
  17. $UI/Start.pressed.connect(_on_start_pressed)
  18. func _on_start_pressed() -> void:
  19. Progress.current_level = _level
  20. get_tree().change_scene_to_file("res://scenes/game.tscn")