game: animate hp bars
This commit is contained in:
@@ -15,7 +15,7 @@ var god_mode: bool = false
|
||||
|
||||
func _ready() -> void:
|
||||
camera.position = global_position
|
||||
main_ui.player_ui.set_hp(100)
|
||||
main_ui.player_ui.update_hp()
|
||||
GlobalConst.sig_debug_god_mode.connect(toggle_god_mode)
|
||||
|
||||
|
||||
@@ -42,13 +42,16 @@ func take_damage(value: float) -> void:
|
||||
player_stats.current_health = clampf(
|
||||
player_stats.current_health, -1.0, player_stats.get_final("max_health", modifiers)
|
||||
)
|
||||
var current_hp = player_stats.get_final("current_health", modifiers)
|
||||
var max_hp = player_stats.get_final("max_health", modifiers)
|
||||
GlobalConst.sig_debug_stats_set.emit("current_health", "%f" % current_hp)
|
||||
GlobalConst.sig_debug_stats_set.emit("max_hp", "%f" % max_hp)
|
||||
|
||||
var dm = preload("res://scenes/damage_numbers.tscn").instantiate()
|
||||
dm.damage_taken = value
|
||||
dm.player_damage = false
|
||||
add_child(dm)
|
||||
main_ui.player_ui.set_hp(
|
||||
(player_stats.current_health / player_stats.get_final("max_health", modifiers)) * 100
|
||||
)
|
||||
main_ui.player_ui.update_hp()
|
||||
if player_stats.current_health <= 0:
|
||||
die()
|
||||
|
||||
|
Reference in New Issue
Block a user