diff options
author | bd <bdunahu@operationnull.com> | 2025-05-21 20:45:06 -0400 |
---|---|---|
committer | bd <bdunahu@operationnull.com> | 2025-05-21 20:45:06 -0400 |
commit | 80e145ba2b85e08f895e76ba6a03bb67bc9ce9ea (patch) | |
tree | ff5f15bedd718d0cfc9daf2963dcf8b3fec88e69 /scenes/crawlers | |
parent | a00b14bcf2084a1e68f57620e27956813d469aad (diff) |
Add basic UI, morale / life logic
Diffstat (limited to 'scenes/crawlers')
-rw-r--r-- | scenes/crawlers/soldier.gd | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/scenes/crawlers/soldier.gd b/scenes/crawlers/soldier.gd index 1bd7549..fe494e6 100644 --- a/scenes/crawlers/soldier.gd +++ b/scenes/crawlers/soldier.gd @@ -1,23 +1,27 @@ extends CharacterBody2D -@export var speed = 50.0 -@export var max_health = 40 -var _health = max_health +@export var worth : int = 5 +@export var damage : int = 1 +@export var speed : float = 50.0 +@export var max_health : float = 30.0 +var _health : float = max_health func _process(delta): get_parent().set_progress(get_parent().get_progress() + speed * delta) if get_parent().get_progress_ratio() == 1: + GameData.subtract_morale(damage) queue_free() func deal_damage(damage): _health -= damage if _health <= 0: + GameData.add_life(worth) queue_free() else: _update_color() func _update_color(): - var ratio : float = float(_health) / max_health + var ratio : float = _health / max_health var target_color = Color(1, ratio, ratio) $Sprite2D.modulate = target_color |