Added player save function to "persistent" tag, added UI elements
This commit is contained in:
31
scripts/hud.gd
Normal file
31
scripts/hud.gd
Normal file
@@ -0,0 +1,31 @@
|
||||
extends Control
|
||||
|
||||
@onready var level_control = get_tree().current_scene
|
||||
@onready var player = level_control.player
|
||||
@onready var stamina_bar: TextureProgressBar = $StaminaBar
|
||||
@onready var health_bar: ProgressBar = $LeftMargin/HealthBar
|
||||
@onready var gun_name: Label = $"MarginContainer/VBoxContainer/Gun Name"
|
||||
@onready var ammo: Label = $MarginContainer/VBoxContainer/Ammo
|
||||
|
||||
# Called when the node enters the scene tree for the first time.
|
||||
func _ready() -> void:
|
||||
health_bar.max_value = level_control.start_health
|
||||
|
||||
|
||||
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||
func _process(delta: float) -> void:
|
||||
player = level_control.player
|
||||
if player != null:
|
||||
health_bar.value = level_control.health
|
||||
if player.remaining_stamina/player.MAX_STAMINA >= .99:
|
||||
stamina_bar.visible = false
|
||||
else:
|
||||
stamina_bar.visible = true
|
||||
stamina_bar.value = player.remaining_stamina
|
||||
|
||||
ammo.text = str(level_control.ammo_current[level_control.current_gun_index]) +" - " + str(level_control.ammo_reserve[level_control.current_gun_index])
|
||||
|
||||
if player.gun != null:
|
||||
gun_name.text = player.gun.gun_name
|
||||
else:
|
||||
gun_name.visible = false
|
||||
Reference in New Issue
Block a user