yippee
This commit is contained in:
parent
077a53d911
commit
6ce339b430
9 changed files with 252 additions and 21 deletions
23
uiman.gd
23
uiman.gd
|
|
@ -3,10 +3,14 @@ extends Control
|
|||
@export var food_bar : ProgressBar
|
||||
@export var snake_manager : Node2D
|
||||
@export var score_label : Label
|
||||
@export var speed_label : Label
|
||||
@export var gameover_score_label : RichTextLabel
|
||||
@export var gameover_screen : MarginContainer
|
||||
|
||||
|
||||
# Called when the node enters the scene tree for the first time.
|
||||
func _ready() -> void:
|
||||
Router.die.connect(show_gameover)
|
||||
pass # Replace with function body.
|
||||
|
||||
|
||||
|
|
@ -15,3 +19,22 @@ func _process(delta: float) -> void:
|
|||
food_bar.max_value = snake_manager.max_food
|
||||
food_bar.value = snake_manager.food
|
||||
score_label.text = str(snake_manager.score)
|
||||
gameover_score_label.text = str(snake_manager.score)
|
||||
if snake_manager.SNAKE_SPEED < snake_manager.max_snake_speed:
|
||||
speed_label.text = str(round(snake_manager.SNAKE_SPEED*100)/100)
|
||||
else:
|
||||
speed_label.text = str(round(snake_manager.max_snake_speed*100)/100) + " MAX"
|
||||
speed_label.label_settings.font_color = Color.RED
|
||||
|
||||
func show_gameover():
|
||||
gameover_screen.show()
|
||||
|
||||
|
||||
func _on_again_button_pressed() -> void:
|
||||
get_tree().get_root().process_mode = Node.PROCESS_MODE_ALWAYS
|
||||
get_tree().change_scene_to_file("res://test.tscn")
|
||||
|
||||
|
||||
func _on_menu_button_pressed() -> void:
|
||||
get_tree().get_root().process_mode = Node.PROCESS_MODE_ALWAYS
|
||||
get_tree().change_scene_to_file("res://scenes/menu.tscn")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue