function RedBoomy_process( inst, key )
	if math.abs( inst.x - inst.target[1] ) < inst.size and math.abs( inst.y - inst.target[2] ) < inst.size then
		RedBoomy_destroy( inst.x, inst.y )
		delete( enemies, key )
	end
end

function RedBoomy_destroy(x, y)
	CreateSimpleBullet( x, y, { 1,  1}, RGB(249, 279, 0) )
	CreateSimpleBullet( x, y, {-1,  1}, RGB(249, 279, 0) )
	CreateSimpleBullet( x, y, {-1, -1}, RGB(249, 279, 0) )
	CreateSimpleBullet( x, y, { 1, -1}, RGB(249, 279, 0) )
	CreateSimpleBullet( x, y, { 0,  2}, RGB(249, 279, 0) )
	CreateSimpleBullet( x, y, { 0, -2}, RGB(249, 279, 0) )
end

function CreateRedBoomy( x, y, target )
	local angle = math.atan( (target[2] - y)/(target[1] - x) )
	local spr = CreateSprite( "sprite", x, y )
	SetObjAnim( spr, 8, false )
	local vel = { math.cos( angle ), math.sin( angle ) }
	if (target[1] < x and vel[1] > 0) or (target[1] > x and vel[1] < 0) then
		vel[1] = -vel[1]
	end
	if (target[2] > y and vel[2] < 0) or (target[2] < y and vel[2] > 0) then
		vel[2] = -vel[2]
	end
	table.insert( enemies,
				{
					sprite = spr,
					x = x,
					y = y,
					size = 16,
					speed = 0.5,
					target = target,
					score = 300,
					vel = vel,
					process = RedBoomy_process,
					destroy = RedBoomy_destroy
				})
end
