Barrel.gd 753 B

1234567891011121314151617181920212223242526272829
  1. extends Enemy
  2. const MOVE_SPEED := 30
  3. const BARREL_DESTRUCTION_PARTICLE = preload("res://Scenes/Prefabs/Particles/BarrelDestructionParticle.tscn")
  4. func _physics_process(delta: float) -> void:
  5. handle_movement(delta)
  6. func handle_movement(delta: float) -> void:
  7. if is_on_wall() and is_on_floor() and get_wall_normal().x == -direction:
  8. die()
  9. func die() -> void:
  10. destroy()
  11. func die_from_object(_node: Node2D) -> void:
  12. destroy()
  13. func summon_particle() -> void:
  14. var node = BARREL_DESTRUCTION_PARTICLE.instantiate()
  15. node.global_position = global_position - Vector2(0, 8)
  16. add_sibling(node)
  17. func destroy() -> void:
  18. summon_particle()
  19. AudioManager.play_sfx("block_break", global_position)
  20. queue_free()
  21. func bounce_up() -> void:
  22. velocity.y = -200