extends KinematicBody2D

onready var bump = $Bump
export var MAX_SPEED = 300
var movement = Vector2.ZERO
var direction = Vector2.ZERO

func _ready():
	change_direction()

func _physics_process(delta):
	movement.x = direction.x * MAX_SPEED * delta
	movement.y = direction.y * MAX_SPEED * delta
	if(move_and_collide(movement)):
		change_direction()
	#print(get_slide_collision(movement))
	
func change_direction():
	var rng = RandomNumberGenerator.new()
	rng.randomize()
	direction.x = rng.randf_range(-1.0, 1.0)
	rng.randomize()
	direction.y = rng.randf_range(-1.0, 1.0)
	direction = direction.normalized()
	rotation_degrees = rad2deg(direction.angle())
	if (!bump.playing):
		bump.play()
	
