options = {}

function think (self,player,params)
	local fx,fy,fz = self.body:local2world(0,-.09,0)
	local x,y,z = self.body:pos()
	self.body:addforce((fx-x)*3,fy-y,0)
	
	
	local rx,ry,rz = self.body:rotdeg()
	local vx,vy,vz = self.body:velocity()
	self.body:rotdeg((rx-self.rx)*.5+self.rx,
		(ry-self.ry)*.5+self.ry,
		(rz-self.rz)*.5+self.rz)
	
	self.reload = math.min(10,(self.reload or 0) + 1)
	
	if math.sin (self.age*.1)>.9 and self.reload>0 then
		self.reload = self.reload -25
		for i,p in ipairs{{10,5,0},{-10,5,0},{15,10,0},{-15,10,0},{20,0,0},{-20,0,0}} do
			local px,py = self.body:local2world(unpack(p))
			local fx,fy = self.body:local2world(0,-6,0)
			
			self.game:fireprojectile("enemylaser",px,py,fx-x,fy-y,1)
		end
	end
	
	if math.sin (self.age*.1)<-.9 and self.reload>0 and not self.game.player.destroyed then
		self.reload = self.reload -25
		local px,py,pz = self.game.player.body:pos()
		local x,y,z =self.body:pos()
		local dx,dy,dz = px-x,py-y,0
		local len = math.sqrt(dx*dx+dy*dy)
		dx,dy = dx/len,dy/len
		for i,p in ipairs{{5,0,0},{-5,0,0}} do
			local x,y = self.body:local2world(unpack(p))
			self.game:fireprojectile("enemylaser",x,y,dx*5,dy*5,1)
		end
	end
	
end

function getPreview()
	return {}
end
