Wheel.gd 505 B

123456789101112131415161718192021222324252627
  1. class_name Wheel
  2. extends RigidBody2D
  3. export var min_linear_speed = 150
  4. export var max_linear_speed = 250
  5. export var max_angular_speed = TAU
  6. func attack(from: Vector2, angle: float):
  7. position = from
  8. var speed = rand_range(min_linear_speed, max_linear_speed)
  9. linear_velocity = Vector2(speed, 0).rotated(angle)
  10. angular_velocity = rand_range(-max_angular_speed, max_angular_speed)
  11. func _on_VisibilityNotifier2D_screen_exited():
  12. die()
  13. func _on_Spawner_reset():
  14. die()
  15. func die():
  16. queue_free()