feat: add the ui display for the user hp; connect it to the scene manager;

This commit is contained in:
2026-09-20 20:16:54 +02:00
parent a252f9419e
commit 1655a9f8cc
2 changed files with 63 additions and 5 deletions
+2 -3
View File
@@ -8,7 +8,7 @@ class_name Player
# Called when the node enters the scene tree for the first time.
func _ready() -> void:
update_scrolls()
print("HP: ", SceneManager.player_hp)
%HealthBar.play("3_hp")
var damage: float = 2
if SceneManager.player_next_scene_spawn_pos != Vector2(0, 0):
position = SceneManager.player_next_scene_spawn_pos
@@ -64,11 +64,10 @@ func _on_area_2d_body_exited(body: Node2D) -> void:
func _on_hit_box_area_2d_body_entered(body: Node2D) -> void:
SceneManager.player_hp -= 1
print("HP: ", SceneManager.player_hp)
%HealthBar.play(str(SceneManager.player_hp) + "_hp")
if SceneManager.player_hp <= 0:
die()
func die():
print("DED")
get_tree().call_deferred("reload_current_scene")
SceneManager.player_hp = 3