Pokey.gd 711 B

1234567891011121314151617181920212223242526
  1. extends Enemy
  2. @export_range(1, 10, 1) var length := 3
  3. var wave := 0.0
  4. func _physics_process(delta: float) -> void:
  5. handle_collision()
  6. handle_part_animation(delta)
  7. func handle_collision() -> void:
  8. $HeadHitbox.position.y = (-length * 16) + 8
  9. $Collision.shape.size.y = (length * 16)
  10. $Collision.position.y = (-length * 8)
  11. $BodyHitbox.position.y = $Collision.position.y
  12. func handle_part_animation(delta: float) -> void:
  13. wave += delta
  14. for i in $Parts.get_children():
  15. if i.get_index() > 0:
  16. i.offset.x = sin(wave * 8) * 1 * [-1, 1][i.get_index() % 2]
  17. func summon_part_gibs() -> void:
  18. for i in $Parts.get_children():
  19. if i.visible:
  20. i.get_node("GibSpawner").summon_gib([-1, 1][i.get_index() % 2])