function jumpjets.init()

 local jumpjet = load_particle("worm_jumpjet.obj")
 local sound_jumpjet = sounds["worm_jumpjet.wav"]
 local soundlength = 49

 function bindings.localplayerEvent(player, event, state)
  if event == Player.Jump then
   player:data().jump = state
   player:data().jumploop = soundlength -1
  end
 end

 function bindings.playerUpdate(player)
  local jump = player:data().jump
  local worm = player:worm()
  if player:data().jump and worm:health() > 0 then

   local loop = player:data().jumploop
   loop = loop + 1
   if loop == soundlength then
    loop = 0
    sound_jumpjet:play(worm,nil,100,1,0)
   end
   player:data().jumploop = loop

   local worm = player:worm()
   worm:push(0,-0.014)
   local x, y = worm:pos()
   if worm:angle() < 180 then
    x = x - 5
   else
    x = x + 5
   end
   for a=1, 3 do
    local flame = worm:shoot(jumpjet, 1, 0, 0, 0, 0, 0, 0, 0)

    flame:set_pos(x,y+1)
    flame:set_spd(math.cos(a)*1+math.random(-10,10)*0.1, 1+math.sin(a)*1+math.random(-10,10)*0.1)
   end
  end    
 end

end
