extends Area2D

export var Force = 2000 #impulse
var impvec
var last_fired = 0

func _ready():
	var angle = get_transform().get_rotation() + PI * 0.5;
	impvec = Vector2(-cos(angle) * Force, -sin(angle) * Force)
	connect("body_entered", self, "_on_ball_enter");

func _on_ball_enter(body):
	if not body.has_method("apply_impulse"):
		return
	var t = OS.get_ticks_msec()
	if t - last_fired < 100: # milliseconds cooldown
		return
	body.apply_impulse(Vector2(0, 0), impvec)
	last_fired = t