class_name Meteor extends "res://scenes/obstacle/obstacle.gd"

@onready var animationPlayer = $AnimationPlayer

@export var minSpeed: int = 100
@export var maxSpeed: int = 1000
@export var minScale: float = 0.5
@export var maxScale: float = 2

var rotated = false

var speed: int = 1000
var offset: int = 0
var direction: int

func _init() -> void:
	var rng = RandomNumberGenerator.new()
	var newScale = rng.randf_range(minScale, maxScale)
	scale = Vector2(newScale, newScale)

	var direction = Vector2.UP.rotated(rotation)
	direction = rng.randi_range(0, 20)
	speed = rng.randi_range(minSpeed, maxSpeed)
	#rotation = direction
	

func _physics_process(delta: float) -> void:
	if not rotated:
		rotated = true
		if Globals.getPlayer() != null:
			look_at(Globals.getPlayer().global_position)
	var rng = RandomNumberGenerator.new()
	

	velocity = Vector2.RIGHT.rotated(rotation+offset).normalized() * speed
	move_and_slide()
