Chicken.gd 513 B

1234567891011121314151617181920212223242526272829303132
  1. class_name Chicken
  2. extends KinematicBody2D
  3. export var walk_linear_speed = 100
  4. export var run_boost = 4
  5. var velocity = Vector2.ZERO
  6. func attack(from: Vector2, angle: float):
  7. position = from
  8. velocity = Vector2(walk_linear_speed, 0).rotated(angle)
  9. $AnimatedSprite.play("walk")
  10. $AnimatedSprite.flip_h = velocity.x < 0.0
  11. func _physics_process(delta):
  12. move_and_collide(velocity * delta)
  13. func _on_VisibilityNotifier2D_screen_exited():
  14. die()
  15. func _on_Spawner_reset():
  16. die()
  17. func die():
  18. queue_free()