--flail
--codename: the holy nutsack

function init()
	board = FindShape("board")
	
	spring = FindJoint("spring")
	
	body = FindBody("springboard")
	
	trig = FindTrigger("activate")
end

function tick(dt)
	local broken = IsShapeBroken(board)
	local active = IsPointInTrigger(trig, GetPlayerTransform().pos)
	local timer = GetFloat("springboard.timer")
	
	if not active then
		SetFloat("springboard.timer", 0.33)
		SetJointMotorTarget(spring, 0, 1)
	else
		SetFloat("springboard.timer", GetFloat("springboard.timer") - dt)
		if timer <= 0 then
			SetJointMotorTarget(spring, 3, 30)
			timer = (timer*0) + 1
		end
	end
	
	--DebugPrint(active)
end