function BossCross_process(v)
	if v.y < -150 then
		return
	end
	v.immortal = false
	v.speed = 0
	v.x = 150*math.sin(v.t)
	v.t = v.t + 0.01
	if (not v.last_shot) or time - v.last_shot > 500 then
			v.last_shot = time
			v.attack = math.random(0, 4)
			if v.attack <= 1 then
				Resume( NewThread( function() 
					for i=1,4 do
						PlaySnd( "shot2.wav", true, v.x, v.y )
						CreateSpriteBullet( v.x+math.random(-16,16), v.y+100, "cross", 1, 3, {1, .8, .8, 1}, -math.pi/2+math.random(-4,4)*math.pi/16 )
						Wait( 100 )
					end
				end ))
			elseif v.attack == 2 then
				PlaySnd( "shot3.wav", true, v.x, v.y )
				CreateSimpleRay( v.x-23, v.y+100, {1, .7, .7, 1} )
				CreateSimpleRay( v.x+23, v.y+100, {1, .7, .7, 1} )
			elseif v.attack == 3 then
				PlaySnd( "shot1.wav", true, v.x, v.y )
				local pl = players[math.random(1, players_num)]
				local angle = math.atan2( pl.y-v.y-28, pl.x-v.x-114 )
				CreateSineBullet( v.x-114, v.y-28, 3, {1, 1, .8, 1}, -angle )
				angle = math.atan2( pl.y-v.y-28, pl.x-v.x+114 )
				CreateSineBullet( v.x+114, v.y-28, 3, {1, 1, .8, 1}, -angle )
			else
				PlaySnd( "shot2.wav", true, v.x, v.y )
				for i=1,3 do
					CreateSimpleBullet( v.x-28, v.y-86, 3, {1, 1, 1, 1}, -math.pi/2+i*math.pi/16 )
					CreateSimpleBullet( v.x-28, v.y-86, 3, {1, 1, 1, 1}, -math.pi/2-i*math.pi/16 )
					CreateSimpleBullet( v.x+28, v.y-86, 3, {1, 1, 1, 1}, -math.pi/2+i*math.pi/16 )
					CreateSimpleBullet( v.x+28, v.y-86, 3, {1, 1, 1, 1}, -math.pi/2-i*math.pi/16 )
				end
			end
	end
end

function BossCross_hit( inst )
	local col = ( inst.max_health - inst.health ) / inst.max_health
	SetObjSpriteColor( inst.sprite, { 1, 0, 0, col }, 0 )
end

function BossCross_destroy( x, y, v, k )
	for i=1,25 do
		CreateExplosion( x + math.random(-100, 100), y + math.random(-100, 100) )
	end
	CreateBulbs()
end

function CreateBossCross()
	PlaySnd("alarm.wav", true)
	local spr = CreateSprite( "cross", 0, -800 )
	local enemy = {
		x = 0,
		y = -800,
		process = BossCross_process,
		boss = true,
		protected = true,
		size = 35,
		speed = 3,
		vel = {0, 1},
		t = 0,
		health = math.floor( 40 * options.enemy_health + 0.5 ),
		max_health = math.floor( 40 * options.enemy_health + 0.5 ),
		hit = BossCross_hit,
		destroy = BossCross_destroy,
		score = 10000,
		immortal = true,
		sprite = spr
	}
	table.insert( enemies, enemy )
end
