Sidebar and lives

This commit is contained in:
2025-03-13 17:25:00 +01:00
parent 43d5ee2b5f
commit 491755209f
6 changed files with 92 additions and 2 deletions

View File

@ -3,6 +3,7 @@ extends Node2D
var speed = 0
var health = 0
var shield = 0
var damage = 0
var current_health = 0
var current_shield = 0
@ -11,6 +12,7 @@ var last_position: Vector2 = Vector2.ZERO # To store the previous position
func _ready() -> void:
last_position = get_parent().position
set_character_data()
adjust_health_bar()
@ -38,6 +40,7 @@ func move_character(delta: float) -> void:
#if reached the end of the path remove both the path, and the character
if path_follow.get_progress_ratio() >= 0.999:
get_parent().get_parent().get_parent().decrease_life(damage)
get_parent().queue_free()
@ -47,14 +50,17 @@ func set_character_data():
speed = 120
health = 100
shield = 100
damage = 2
"Ork":
speed = 80
health = 150
shield = 100
damage = 5
"Cobold":
speed = 200
health = 50
shield = 0
damage = 1
get_node("CharacterBody2D/AnimatedSprite2D").speed_scale = float(speed) / 100 #adjust animation speed based on the character speed
current_health = health