function rubyblitz.init()

 local gun_rail = load_particle("rubyblitz_gun_rail.obj")
 local gun_ruby = load_particle("rubyblitz_gun_ruby.obj")
 local spike = load_particle("rubyblitz_spike_maker.obj")

 local level_0 = load_particle("rubyblitz_level_0.obj")

 local level_1_side = load_particle("rubyblitz_level_1_side.obj")
 local level_1_center = load_particle("rubyblitz_level_1_center.obj")


 local level_2_side = load_particle("rubyblitz_level_2_side.obj")
 local level_2_center = load_particle("rubyblitz_level_2_center.obj")

 local power_up = 0.3
 local power_drain_factor = 0.99
 local power_drain_linear = 0.01
 local power_treshold = 0.098

 local level_1 = 6
 local level_2 = 13

 local sound_loop_1 = sounds["rubyblitz_loop_1.wav"]
 local sound_loop_2 = sounds["rubyblitz_loop_2.wav"]

 function rubyblitz.gun(worm)

  local angle = worm:angle()
  local dx, dy = angle_vector(angle,3)

  local rail = worm:shoot(gun_rail, 1, 0, 0, 0, 0, 0, 0, 2)
  rail:set_spd(dx,dy)

  local rubyblitz_glow = worm:data().rubyblitz_glow
  local rubyblitz_dglow = worm:data().rubyblitz_dglow
  local rubyblitz_power = worm:data().rubyblitz_power

  if rubyblitz_power then

   local x,y = worm:pos()
   rubyblitz_power = rubyblitz_power * power_drain_factor - power_drain_linear

   worm:shoot(spike, rubyblitz_power*0.5 + 1, 0, 0, 0, 0, 0, -x*2 - y*3 + 0.5*angle, 0)
   worm:shoot(spike, rubyblitz_power*0.5 + 1, 0, 0, 0, 0, 0,  x*3 - y*3 + 0.3*angle, 0)
   worm:shoot(spike, rubyblitz_power*0.5 + 1, 0, 0, 0, 0, 0,  x*2 + y*2 - 0.5*angle, 0)
   worm:shoot(spike, rubyblitz_power*0.5 + 1, 0, 0, 0, 0, 0, -x*3 + y*2 - 0.3*angle, 0)

   if rubyblitz_power < level_1 then
    worm:shoot(level_0, rubyblitz_power*0.5 + 1, 1, 0, 0, 0, 0, 0, 4)
   elseif rubyblitz_power < level_2 then

    for a=0, (rubyblitz_power + 1 - level_1) * 0.5 do
     local left = worm:shoot(level_1_side, 1, 0, 0, 0, 0, 0, -30, 2)
     local right = worm:shoot(level_1_side, 1, 0, 0, 0, 0, 0, 30, 2)
     left:set_spd(dx,dy)
     right:set_spd(dx,dy)
    end
    
    worm:shoot(level_1_center, rubyblitz_power * 10 % 8, 1, 0, 0, 0, 0, 0, 4)
    worm:shoot(level_0, rubyblitz_power * 0.5 + 1, 1, 0, 0, 0, 0, 0, 4)

   else

    local left = worm:shoot(level_2_side, 1, 0, 0, 0, 0, 0, -30, 2)
    local right = worm:shoot(level_2_side, 1, 0, 0, 0, 0, 0, 30, 2)
    left:set_spd(dx,dy)
    right:set_spd(dx,dy)
    
    worm:shoot(level_2_center, 1, 1, 0, 0, 0, 0, 0, 4)

   end



   if rubyblitz_power < power_treshold then
    rubyblitz_power = nil
   end

   worm:data().rubyblitz_power = rubyblitz_power
  else

   if rubyblitz_glow then
    rubyblitz_glow = rubyblitz_glow + rubyblitz_dglow
    for a=0, rubyblitz_glow do
     local ruby = worm:shoot(gun_ruby, 1, 0, 0, 0, 0, 0, 0, 2)
     ruby:set_spd(dx, dy)
    end
    if rubyblitz_glow > 8 or rubyblitz_glow < 1 then
     rubyblitz_dglow = -rubyblitz_dglow
    end
   else
    rubyblitz_glow = 1
    rubyblitz_dglow = 0.11
   end
  end

  worm:data().rubyblitz_glow = rubyblitz_glow
  worm:data().rubyblitz_dglow = rubyblitz_dglow
  
 end

 function rubyblitz.shoot(worm)

  local rubyblitz_power = worm:data().rubyblitz_power
  local rubyblitz_loop = worm:data().rubyblitz_loop

  if rubyblitz_power then
   rubyblitz_power = rubyblitz_power + power_up
  else
   rubyblitz_power = power_up
  end

  if not rubyblitz_loop then
   rubyblitz_loop = 1
   sound_loop_1:play(worm, nil, 100, 1, 0)
  end
  rubyblitz_loop = rubyblitz_loop + 1
  if rubyblitz_loop > 24 then
   rubyblitz_loop = 1
   if rubyblitz_power < level_2 then 
    sound_loop_1:play(worm, nil, 100, 1, 0)
   else
    sound_loop_2:play(worm, nil, 100, 1, 0)
   end
  end
  

  worm:data().rubyblitz_loop = rubyblitz_loop
  worm:data().rubyblitz_power = rubyblitz_power
 end

end