function StarThingy_process( v, key )
	if not v.reached  then
		if dist( v.x, v.y, v.target[1], v.target[2] ) < 32 then
			v.reached = true
			v.speed = 0
		end
	else
		if v.spent and (math.abs( v.x ) > 300 or math.abs( v.y ) > 400) then
			delete( enemies, key )
		elseif time - v.last_shot > (100 * options.enemy_reload) then
				PlaySnd( "shot1.wav", true, v.x, v.y )
				CreateSimpleBullet( v.x, v.y, 3, { .8, .6, .2, 1 }, v.sangle )
				v.sangle = v.sangle + 10*math.pi/180
				if v.sangle >= 5.5*math.pi then
					v.spent = true
					v.speed = 2
				end
				v.last_shot = time
		end
	end
end

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

function CreateStarThingy( x, y, target )
	local spr = CreateSprite( "sprite", x, y )
	SetObjAnim( spr, 27, false )
	local angle = math.atan2( target[2]-y, target[1]-x )
	table.insert( enemies,
				{
					sprite = spr,
					x = x,
					y = y,
					size = 16,
					speed = 2,
					health = math.floor( 6 * options.enemy_health + 0.5 ),
					target = target,
					max_health = math.floor( 6 * options.enemy_health + 0.5 ),
					score = 500,
					sangle = -math.pi/2,
					last_shot = 0,
					vel = { math.cos(angle), math.sin(angle) },
					process = StarThingy_process,
					hit = StarThingy_hit,
				} )
end
