fuzzyworld

godot-shooter / commit

Add health to player.

c7a34446481773a786bc69fe106e9eb60bcbc4fc · Pavel Safronov · 2023-10-31 16:58:03 -0700 · parents d9bff51f7379

Add health to player.
 Player.gd   |  2 ++
 Player.tscn | 11 +++++++++++
 2 files changed, 13 insertions(+)

diff --git a/Player.gd b/Player.gd
index 56ea036..7cc0481 100644
--- a/Player.gd
+++ b/Player.gd
@@ -25,6 +25,8 @@ func _process(delta: float) -> void:
 		return
 	if Input.is_action_pressed("shoot"):
 		shoot()
+	$Graphics/Alive/Control/HealthLabel.text = "%s / %s" % [health, max_health]
+	$Graphics/Alive/Control.global_rotation = 0
 
 
 func _physics_process(delta: float) -> void:
diff --git a/Player.tscn b/Player.tscn
index e88b837..9693535 100644
--- a/Player.tscn
+++ b/Player.tscn
@@ -19,6 +19,17 @@ polygon = PoolVector2Array( -24, 17, 0, 8, 24, 17, 24, 0, 0, -16, -24, 0 )
 [node name="Alive" type="Sprite" parent="Graphics"]
 texture = ExtResource( 1 )
 
+[node name="Control" type="Node2D" parent="Graphics/Alive"]
+
+[node name="HealthLabel" type="Label" parent="Graphics/Alive/Control"]
+margin_left = -25.0036
+margin_top = 21.9958
+margin_right = 24.9964
+margin_bottom = 35.9958
+text = "HEALTH"
+align = 1
+uppercase = true
+
 [node name="Dead" type="Sprite" parent="Graphics"]
 visible = false
 texture = ExtResource( 2 )