game: add xp orbs

This commit is contained in:
2025-08-19 15:31:32 +02:00
parent 8fc3cf4838
commit 42fd207906
4 changed files with 22 additions and 0 deletions

View File

@@ -15,6 +15,7 @@ var max_health: float
var god_mode: bool = false
var is_dead: bool = false
var _xp_orb = preload("res://scenes/xp_orb.tscn")
func _ready() -> void:
move_speed = default_move_speed
@@ -57,11 +58,17 @@ func die():
if is_dead:
return
is_dead = true
drop_xp_orb()
target = null
velocity = Vector2.ZERO
animation_player.play("die")
animation_player.animation_finished.connect(_on_die_anim_finished)
func drop_xp_orb() -> void:
var orb: XPOrb = _xp_orb.instantiate()
orb.value = 5
orb.position = position
get_parent().add_child(orb)
func cheer_anim():
if not animation_player.is_playing():