------ All content © 2008 DigiPen (USA) Corporation, all rights reserved. ------
--------------------------------------------------------------------------------
-- Fuctions!
-- This might look redundant, but avoids costly global lookup
--------------------------------------------------------------------------------

local GLOBAL_TimeElapsed             = Global.TimeElapsed
local GLOBAL_DeleteEntityByPtr       = Global.DeleteEntityByPtr
local GLOBAL_FireflySpawnMsg         = Global.FireflySpawnMsg

local ENTITY_GetMyPointer            = Entity.GetMyPointer

--------------------------------------------------------------------------------
-- Variables
--------------------------------------------------------------------------------
local myData = {}
local SPAWN_TIME = 3000
local SPAWN_COUNT = 50

--------------------------------------------------------------------------------
-- Loop
--------------------------------------------------------------------------------
local elapsedSpawns = 0
local elapsedTime = 0
while( 1 ) 
do
  coroutine.yield()

  elapsedTime = elapsedTime + GLOBAL_TimeElapsed()

  --spawn more fireflies
  if( elapsedTime >= SPAWN_TIME )
  then
    elapsedTime = 0
    elapsedSpawns = elapsedSpawns + 1
    GLOBAL_FireflySpawnMsg( 330, 0, 0, 280, 300, -185, 5, 4 )

  end

  --kill the entity when we're done
  if( elapsedSpawns >= SPAWN_COUNT )
  then
    GLOBAL_DeleteEntityByPtr( ENTITY_GetMyPointer( Entity ) )

  end

end
