BobOmbHeld.gd 851 B

1234567891011121314151617181920212223242526272829303132333435
  1. extends Enemy
  2. const EXPLOSION = preload("uid://clbvyne1cr8gp")
  3. @export var timer := 5.0
  4. var can_move := true
  5. func _ready() -> void:
  6. $Movement.auto_call = can_move
  7. func _physics_process(delta: float) -> void:
  8. timer -= delta
  9. if timer <= 2.0:
  10. %FlashAnimation.play("Flash")
  11. if timer <= 0:
  12. explode()
  13. timer = 99
  14. %Sprite.scale.x = direction
  15. func explode() -> void:
  16. $AnimationPlayer.play("Explode")
  17. await $AnimationPlayer.animation_finished
  18. summon_explosion()
  19. queue_free()
  20. func kick(object: Node2D) -> void:
  21. AudioManager.play_sfx("kick", global_position)
  22. var kick_dir = sign(global_position.x - object.global_position.x)
  23. velocity.x = 150 * kick_dir
  24. direction = kick_dir
  25. velocity.y = -100
  26. func summon_explosion() -> void:
  27. var node = EXPLOSION.instantiate()
  28. node.global_position = global_position + Vector2(0, -8)
  29. add_sibling(node)