ObjectData = 
{
	MotionModel = 
	{
		DefaultAnimation = [[normal]],
		Motions = 
		{
			motion1 = 
			{
				Animations = 
				{
					anim1 = 
					{
						Path = [[DATA:Animations\firefly\firefly_green.anim]],
						Name = [[firefly]],
						MinFreq = 1.000000,
						MaxFreq = 1.000000,
					},
				},
				Name = [[normal]],
			},
			motion2 = 
			{
				Animations = 
				{
					anim1 = 
					{
						Path = [[DATA:Animations\firefly\firefly_green.anim]],
						Name = [[firefly]],
						MinFreq = 1.000000,
						MaxFreq = 1.000000,
					},
				},
				Name = [[toolbar]],
			},
		},
	},
	Extensions = 
	{
		PhysicsExtension = 
		{
		},
		PositionExtension = 
		{
		},
		LevelEditorExtension = 
		{
			blocks_items = false,
			locked = true,
		},
		LightingExtension = 
		{
			red = 0.000000,
			green = 110.000000,
			blue = 0.000000,
			light_enabled = true,
			outer_radius = 30,
			inner_radius = 30,
			height = 15,
			gphx_only = true,
			update_while_playing = true
		},
	},
}-- Begin Scripting --

help_text_header = "$00626"
help_text = "$00628"

function OnInit()
	
	--remember where i was
	original_height = this:GetPosition().y
	original_width = this:GetPosition().x
	
	this:EnableCollisions(false)
	this:EnablePhysics(false)
	
	index_on_sine = 0
	index_increment = math.pi/(60+60*World_GetDeterministicDouble())
		
	if World_GetDeterministicDouble() > 0.5 then
		index_on_sine_x = math.pi
	else
		index_on_sine_x = 0
	end
	
	index_increment_x = math.pi/(80+60*World_GetDeterministicDouble())
	
	MAX_HEIGHT = 20+(10*World_GetDeterministicDouble())
	MAX_WIDTH = 30+(10*World_GetDeterministicDouble())
	
	local size = 0.8 + 0.4*World_GetDeterministicDouble()
	this:SetScale( Vector2(size, size) )
		
end

--require "util.lua"


function Update()

	Profile_Start("firefly")

	local pos = this:GetPosition()

	height = math.sin( index_on_sine )*MAX_HEIGHT
	index_on_sine = index_on_sine + index_increment
	
	if index_on_sine >= math.pi*2 then
		index_on_sine = index_on_sine - math.pi*2
	end

	width = math.sin( index_on_sine_x )*MAX_WIDTH
	index_on_sine_x = index_on_sine_x + index_increment_x
	
	if index_on_sine_x >= math.pi*2 then
		index_on_sine_x = index_on_sine_x - math.pi*2
	end
	
	this:SetPosition( Vector2( original_width + width, original_height + height ) )
		
	this:SetFlipped( index_on_sine_x > math.pi/2 and index_on_sine_x < 3*math.pi/2 ) 
	
	Profile_Stop("firefly")
		
end

