BomberBossEnemy = class(CloudBossEnemy, function(o, x, y, world, ...)
	pd:startList("fromOF")
	pd:addSymbol("bomber_boss_on")
	pd:addFloat(1)
	pd:finish("fromOF")		
	CloudBossEnemy.init(o,x,y,world, {animation={'boss_plane.svg'}, settingName='bomber_boss_'})
	o.shootRate = game_settings["bomber_boss_shoot_rate"] or 2
	o.shootCount = o.shootRate
	bludG.camera:shake(1.5)
end)
function BomberBossEnemy:sync()
	if not Enemy.sync(self) then return end
	if not self.alive then return end
	if self.moveRate > 0 then
		self.moveRate = self.moveRate - 1
	else
		self.moveRate = self.moveCount
		self:move()
	end
	if self.shootCount > 0 then
		self.shootCount = self.shootCount - 1
	else
		self.shootCount = self.shootRate
		self:shootBomb()
	end
end
function BomberBossEnemy:shootBomb()
	if not self.alive then return end
	local l = self.world.enemyBullets:addRecycle(BombDropEnemy(self.pos.x, self.pos.y, self.world))
	l.pos.x, l.pos.y = self.pos.x, self.pos.y
	l.acceleration.y = 200*r_scale
	if self.moveDirection == 'left' then
		self.mouthPosition.x = self.w - self.mouthPosition.x
		l.pos:add(self.mouthPosition)
		self.mouthPosition.x = self.w - self.mouthPosition.x
	else
		l.pos:add(self.mouthPosition)
	end
	if l:center().x > self.world.rootRoom:center().x then
		l.flip = 1
	end
	pd:startList("fromOF")
	pd:addSymbol("bomber_boss_shoot")
	pd:addFloat(1)
	pd:finish("fromOF")
end
function BomberBossEnemy:move()
	if not self.alive then return end
	local moveSpeed = 100*r_scale
	local limits = self.world:getTowerLimits()
	if self.moveDirection == 'right' then
		self.velocity.x = moveSpeed;
		if self.pos.x > limits.maxX then
			self.moveDirection = 'left'
		end
	else
		self.velocity.x = -moveSpeed;
		if self.pos.x+self.w < limits.minX then
			self.moveDirection = 'right'
		end
	end
	self.idleAnimation:startAnimation()
end

function BomberBossEnemy:update()
	if not self.alive then return end
	if self.world.over then return end
	local braking = 60
	local bounceDistance = 100
	self.acceleration.x, self.acceleration.y = 0,0
	if retina then braking = braking*2; bounceDistance = bounceDistance*2 end
	-- check to see if we need to avoid the building
	local limits = self.world:getTowerLimits()
	-- limits.minY
	if limits.minY then
		if self:center().y+bounceDistance*1.3 > limits.minY then
			self.acceleration.y = -braking*2
			self.drag.y = braking
		elseif limits.minY - self:center().y > bounceDistance*2 then
			self.acceleration.y = braking*2
			self.drag.y = braking
		end
	end
	CloudEnemy.update(self)
	self.timeWaits:update()
end

-- mainState = WrapperState(Group());
-- mainState:changeState(TitleScreenState())
-- mainState.substate.playButton.onPress()
-- mainState.substate.playButton.onPress()
-- mainState.substate.playButton.onPress()

-- mainState.substate.enemies:addRecycle(BomberBossEnemy(0, bludG.camera.h/2, mainState.substate))
