game: add enemy taunt on death

This commit is contained in:
2025-08-19 08:39:50 +02:00
parent a661c02e83
commit 59a8a4a8f3
4 changed files with 104 additions and 4 deletions

View File

@@ -40,6 +40,10 @@ func take_damage(value: float) -> void:
return
health -= value
print_debug("player took damage. now has %s hp" % health)
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(health / max_health * 100)
if health <= 0:
die()
@@ -48,7 +52,9 @@ func die():
dead = true
remove_from_group("damagable")
get_tree().call_group("enemy", "cheer_anim")
GlobalConst.sig_stop_spawning.emit(true)
sprite_2d.z_index += 10
get_taunted()
func death_animation(delta: float):
# Engine.time_scale = clampf(lerpf(Engine.time_scale, 0.25, 0.5), 0.25, 0.9*delta)
@@ -57,7 +63,25 @@ func death_animation(delta: float):
if rotation_degrees > 88:
main_ui.pause_ui.toggle_pause_ui()
death_anim_done = true
func get_taunted():
var taunting_enemies: Array[Enemy] = []
for body in get_tree().get_nodes_in_group(GlobalConst.GROUP_ENEMY):
if global_position.distance_to(body.global_position) < 500.0:
taunting_enemies.append(body)
for i in range(taunting_enemies.size()):
var angle = (TAU / taunting_enemies.size()) * i
var target_pos = Vector2(cos(angle), sin(angle)) * 50
print_debug("my_pos: %s" % position)
print_debug("pos: %s" % target_pos)
var new_target = StaticBody2D.new()
var collision = CollisionShape2D.new()
new_target.position = target_pos
add_child(new_target)
new_target.add_child(collision)
taunting_enemies[i].target = new_target
func toggle_god_mode(value: bool):
god_mode = value