Пример #1
0
Файл: typemgr.c Проект: xyuan/ug
static void ConstructDesc (TYPE_DESC *desc)
{
  InitHandlers(desc);

  desc->nPointers = 0;
  desc->nElements = 0;
  desc->cmask     = NULL;
#if defined(CPP_FRONTEND)
  desc->size = 0;
#endif
  desc->hasHeader = FALSE;
  desc->offsetHeader = 0;

}
Пример #2
0
void AvHParticleEditorHandler::SetEditIndex(uint32 inIndex)
{
	bool theReloadValues = false;
	if(sEditIndex != inIndex)
	{
		theReloadValues = true;
	}
	
	sEditIndex = inIndex;

	if(theReloadValues)
	{
		// Init handlers in case we are in edit mode currently
		InitHandlers();
	}
}
Пример #3
0
void CWelcomeDialog::InitFooter(wxString const& resources)
{
#if FZ_WINDOWS && FZ_MANUALUPDATECHECK
	if (CBuildInfo::GetBuildType() == _T("official") && !COptions::Get()->GetOptionVal(OPTION_DISABLE_UPDATE_FOOTER)) {
		if (!resources.empty()) {
			wxLogNull null;

			wxXmlResource res(wxXRC_NO_RELOADING);
			InitHandlers(res);
			if (res.Load(_T("blob:") + resources)) {
				CreateMessagePanel(*this, "ID_HEADERMESSAGE_PANEL", res, _T("ID_WELCOME_HEADER"));
				CreateMessagePanel(*this, "ID_FOOTERMESSAGE_PANEL", res, _T("ID_WELCOME_FOOTER"));
			}
		}
	}
#else
	(void)resources;
#endif
}
Пример #4
0
/*
 * This loop is used to forward incoming Hti messages(arriving from CommChannelPlugin to m_QueueOut side) to correct SoapHandlers
 */
void HtiDispatcher::Run()
{
	Util::Debug("HtiDispatcher::Run");
	//m_testHandler.SetDispatcher(this);
	//m_testHandler.Start();
	InitHandlers();
	StartHandlers();

	BYTE* shortData = NULL; //keep data if it's too short to have HtiHeader
							//or if one Data msg have more than one HtiMessage
	DWORD msgBufferSize = 8096;
	BYTE* msgBuffer = (BYTE*)malloc( msgBufferSize );
	DWORD shortDataLen = 0;

	// By setting this threads priority below others will give soaphandler threads 
	// more runtime to process the received messages.. This is to avoid the situation
	// where two messages arrive so close to each other that m_hReceiveHtiEvent is 
	// signalled twice before the first message has even been processed by the soap plugin.
	if(!SetThreadPriority( ThreadHandle(), THREAD_PRIORITY_BELOW_NORMAL ))
		Util::Info("Warning: Could not set HtiDispatcher priority!");
	
	while (m_Running)
	{
		try
		{	
			Data* d = m_QueueOut->front(50);
			BYTE* p = (BYTE *)d->GetData();
			DWORD l = d->GetLength();
			//printf("\td = %d\n", m_QueueOut->size());

			if (Util::GetVerboseLevel() == Util::VerboseLevel::debug)
			{
				char tmp[64];
				sprintf(tmp, "[HtiDispatcher] HTI MsgSize = %d", l);
				string s(tmp);
				Util::Debug(s);
				//Util::Hex(p, d->GetLength());
			}

			//Util::Debug("leftovers");
			//copy leftovers to the beginning of the buffer
			if ( shortDataLen > 0 )
			{
				memcpy( msgBuffer, shortData, shortDataLen );
			}
			shortData = msgBuffer; //set shortData to the beginning

			//copy data to buffer
			if ( shortDataLen + l > msgBufferSize )
			{
				msgBufferSize = shortDataLen + l;
				msgBuffer = (BYTE*)realloc(msgBuffer, msgBufferSize);
				shortData = msgBuffer;
			}
			//copy data gotten from queue to the end of shortData
			memcpy(shortData + shortDataLen, p, l );
			shortDataLen = l + shortDataLen;

			while ( shortDataLen != 0 &&
				    (shortDataLen >= HtiMessage::MinHeaderSize() ||
				    m_IncomingHtiMessage != NULL ) )
			{
				//new message
				if ( m_IncomingHtiMessage == NULL )
				{
					if ( shortDataLen >= HtiMessage::MinHeaderSize() )
					{
						if ( HtiMessage::CheckValidHtiHeader(shortData) )
						{
							m_IncomingHtiMessage = new HtiMessage( shortData, shortDataLen );

							if (Util::GetVerboseLevel() == Util::VerboseLevel::debug)
							{
								char tmp[64];
								sprintf(tmp,"New hti message %d", m_IncomingHtiMessage->HtiDataSize());
								string s(tmp);
								Util::Debug(s);
								//Util::Hex(p, d->GetLength());
							}
							
							//_RPT2(_CRT_WARN, "income msg %x <%d>\n", m_IncomingHtiMessage, sizeof(HtiMessage));
							//check message
							if ( m_IncomingHtiMessage->IsMessageComplete() )
							{
								Util::Debug("HTI message complete");
								DWORD msgSize = m_IncomingHtiMessage->HtiDataSize();
								if (  msgSize < shortDataLen  )
								{
									//remove used part
									//BYTE* temp = new BYTE[shortDataLen-msgSize];
									//_RPT2(_CRT_WARN, "temp %x <%d>\n", shortData , shortDataLen-msgSize);
									//memcpy(temp, shortData + msgSize, shortDataLen-msgSize);
									//_RPT1(_CRT_WARN, "del shortData %x\n", shortData);
									//delete[] shortData;
									//shortData = temp;
									shortData += msgSize; //just move pointer
									shortDataLen -= msgSize;

								}
								else
								{
									//_RPT1(_CRT_WARN, "del shortData %x\n", shortData);
									//delete[] shortData;
									//shortData = NULL;
									shortDataLen = 0;
								}
								//Dispatch incoming message
								DispatchToSoapHandlers();
							}
							else
							{
								//_RPT1(_CRT_WARN, "del shortData %x\n", shortData);
								//delete[] shortData;
								//shortData = NULL;
								shortDataLen = 0;
							}
						}
						else
						{
							//invalid header
							Util::Error("Invalid HTI header, dismiss Data message");
							Util::Hex(shortData, HtiMessage::MinHeaderSize() );
							//_RPT1(_CRT_WARN, "del shortData %x\n", shortData);
							//delete[] shortData;
							//shortData = NULL;
							shortDataLen = 0;
						}
					}
				}
				else //body parts
				{
					Util::Debug("add");
					DWORD added = m_IncomingHtiMessage->AddToBody( shortData,
																   shortDataLen );
					//printf("reminder %d\n", m_IncomingHtiMessage->Reminder());
					if ( added < shortDataLen )
					{
						//only part of message was added
						//remove added part
						//BYTE* temp = new BYTE[shortDataLen-added];
						//_RPT2(_CRT_WARN, "temp %x <%d>\n", shortData , shortDataLen-added);
						//memcpy(temp, shortData + added, shortDataLen-added);
						//_RPT1(_CRT_WARN, "del shortData %x\n", shortData );
						//delete[] shortData;
						//shortData = temp;
						shortData += added;
						shortDataLen -= added;
					}
					else //all data were added
					{
						//_RPT1(_CRT_WARN, "del shortData %x\n", shortData );
						//delete[] shortData;
						//shortData = NULL;
						shortDataLen = 0;
					}

					if ( m_IncomingHtiMessage->IsMessageComplete() )
					{
						Util::Debug("HTI message complete");
						//Dispatch incoming message
						DispatchToSoapHandlers();
					}
				}
			}

			m_QueueOut->pop();
			//_RPT1(_CRT_WARN, "del data %x\n", d);
			delete d;
			d = NULL;
		} catch (TimeoutException te)
		{
			//Util::Debug("[DataGatewaySocketWriterThread]timeout exception");
		}
	}
	free( msgBuffer );
}
Пример #5
0
void CShooterGame::Initialize()
{
    // Must call base class initializations first
    CGame::Initialize();

    #ifdef DEBUG
    cout << "CShooterGame::Initialize() called" << endl;
    #endif

    auto& renderer = CSingleton<CRenderer>::Instance();

    SDL_WM_SetCaption("Space Attackers!", "Space Attackers!");

    auto screen = renderer->GetScreen();
    m_iScreenW = screen->w;
    m_iScreenH = screen->h;

    // Create global mutex using Factory pattern
    {
        // Prepare Mutex singleton for access from multiple threads at the same time
        MutexFactory::Instance()->Initialize( RESOURCE::MUTEX_MAINAPP );
    }

    // Prepare rand() for multithreaded execution
    {
        CSingleton<CRandom>::Instance()->nextNumber();
    }

    // Load window icon using Factory pattern
    {
        ImageColorkeyFactory::Instance()->Get( RESOURCE::WINDOW_ICON )->Load( "Assets/Icon/icon.bmp" );
        ImageColorkeyFactory::Instance()->Get( RESOURCE::WINDOW_ICON )->SetColorKeyRGB( 0, 255, 255 );
        SDL_WM_SetIcon( ImageColorkeyFactory::Instance()->Get( RESOURCE::WINDOW_ICON )->GetSurface(), 0 );
    }

    // Load sprites using Factory pattern
    {
        ImageAlphaFactory::Instance()->Get( RESOURCE::PLAYER_PLANE )->Load( "Assets/Sprites/player_plane.png" );
        ImageAlphaFactory::Instance()->Get( RESOURCE::PLAYER_PLANE_HIT )->Load( "Assets/Sprites/player_plane_hit.png" );
        ImageAlphaFactory::Instance()->Get( RESOURCE::PLAYER_PLANE_SHADOW )->Load( "Assets/Sprites/player_plane_shadow_0.5x.png" );
        AnimationFactory::Instance()->Get( RESOURCE::PLAYER_PLANE )->LoadAnimation( "Assets/Sprites/player_plane.anim" );
        AnimationFactory::Instance()->Get( RESOURCE::PLAYER_PLANE_SHADOW )->LoadAnimation( "Assets/Sprites/player_plane_shadow_0.5x.anim" );

        ImageAlphaFactory::Instance()->Get( RESOURCE::PLAYER_PROJECTILE )->Load( "Assets/Sprites/plasma_up_yellow.png" );
        ImageAlphaFactory::Instance()->Get( RESOURCE::PLAYER_PROJECTILE_GUIDED )->Load( "Assets/Sprites/plasma_ball_blue.png" );

        ImageAlphaFactory::Instance()->Get( RESOURCE::ENEMY_PROJECTILE_SLOW )->Load( "Assets/Sprites/plasma_ball_green.png" );
        ImageAlphaFactory::Instance()->Get( RESOURCE::ENEMY_PROJECTILE_FAST )->Load( "Assets/Sprites/plasma_ball_red.png" );

        ImageAlphaFactory::Instance()->Get( RESOURCE::ENEMY_PLANE_GREEN )->Load( "Assets/Sprites/plane_green_down.png" );
        ImageAlphaFactory::Instance()->Get( RESOURCE::ENEMY_PLANE_RED )->Load( "Assets/Sprites/plane_red_down.png" );
        ImageAlphaFactory::Instance()->Get( RESOURCE::ENEMY_PLANE_GREEN_HIT )->Load( "Assets/Sprites/plane_green_down_hit.png" );
        ImageAlphaFactory::Instance()->Get( RESOURCE::ENEMY_PLANE_RED_HIT )->Load( "Assets/Sprites/plane_red_down_hit.png" );
        ImageAlphaFactory::Instance()->Get( RESOURCE::ENEMY_PLANE_SHADOW )->Load( "Assets/Sprites/plane_down_shadow_0.5x.png" );

        ImageAlphaFactory::Instance()->Get( RESOURCE::EXPLOSION )->Load( "Assets/Sprites/explosion.png" );
        AnimationFactory::Instance()->Get( RESOURCE::EXPLOSION )->LoadAnimation( "Assets/Sprites/explosion.anim" );
    }

    // Create interpolation sets for intro screen and level start message
    {
        auto& introOverTime = InterpolationSetFactory::Instance()->Get( RESOURCE::IS_INTRO_SHOW );
        introOverTime->AddValue( 0.0f, 0 );
        introOverTime->AddValue( 0.5f, 255, Math::Interpolation::easeOutCirc<float,float> );
        introOverTime->AddValue( 3.5f, 255 );
        introOverTime->AddValue( 5.0f, 0, Math::Interpolation::easeInCirc<float,float> );

        auto& levelStartOverTime = InterpolationSetFactory::Instance()->Get( RESOURCE::IS_LEVEL_START );
        levelStartOverTime->AddValue( 0.0f, m_iScreenH );
        levelStartOverTime->AddValue( 1.5f, m_iScreenH/2 - 32, Math::Interpolation::easeOutCirc<float,float> );
        levelStartOverTime->AddValue( 3.5f, m_iScreenH/2 - 32 );
        levelStartOverTime->AddValue( 5.0f, -64, Math::Interpolation::easeInCirc<float,float> );

    }

    // Load menu sprites using Factory pattern
    {
        ImageAlphaFactory::Instance()->Get( RESOURCE::MENU_TEXT )->Load( "Assets/Menu/texts.png" );
        ImageAlphaFactory::Instance()->Get( RESOURCE::MENU_TEXT_SELECTED )->Load( "Assets/Menu/texts_selected.png" );
        AnimationFactory::Instance()->Get( RESOURCE::MENU_TEXT )->LoadAnimation( "Assets/Menu/texts.anim" );
    }

    // load backgrounds using Factory pattern
    {
        ImageAlphaFactory::Instance()->Get( RESOURCE::BACKGROUND_INTRO )->Load( "Assets/Backgrounds/intro_screen.png" );
        ImageAlphaFactory::Instance()->Get( RESOURCE::BACKGROUND_TITLE )->Load( "Assets/Backgrounds/title_screen.png" );
        ImageAlphaFactory::Instance()->Get( RESOURCE::BACKGROUND_DEATH )->Load( "Assets/Backgrounds/death.png" );
        ImageAlphaFactory::Instance()->Get( RESOURCE::BACKGROUND_HELP1 )->Load( "Assets/Backgrounds/help1.png" );
        ImageAlphaFactory::Instance()->Get( RESOURCE::BACKGROUND_HELP2 )->Load( "Assets/Backgrounds/help2.png" );
        ImageAlphaFactory::Instance()->Get( RESOURCE::BACKGROUND_MOONSURFACE )->Load( "Assets/Backgrounds/moon.png" );
        ImageAlphaFactory::Instance()->Get( RESOURCE::BACKGROUND_CLOUDS1 )->Load( "Assets/Backgrounds/clouds1_tr50.png" );
        ImageAlphaFactory::Instance()->Get( RESOURCE::BACKGROUND_CLOUDS2 )->Load( "Assets/Backgrounds/clouds2_tr50.png" );
        ImageAlphaFactory::Instance()->Get( RESOURCE::BACKGROUND_MOONSURFACE )->SetAlpha(255);
        ImageAlphaFactory::Instance()->Get( RESOURCE::BACKGROUND_CLOUDS1 )->SetAlpha(0);
        ImageAlphaFactory::Instance()->Get( RESOURCE::BACKGROUND_CLOUDS2 )->SetAlpha(0);
        // Create layers and set the bitmaps
        ScrollingBackgroundFactory::Instance()->Get( RESOURCE::SCROLLING_MOONSURFACE )->Initialize(1);
        ScrollingBackgroundFactory::Instance()->Get( RESOURCE::SCROLLING_CLOUDS )->Initialize(2);

        auto& moonSurfaceLayer = ScrollingBackgroundFactory::Instance()->Get( RESOURCE::SCROLLING_MOONSURFACE );
        moonSurfaceLayer->SetLayer( 0, RESOURCE::BACKGROUND_MOONSURFACE );
        moonSurfaceLayer->SetLayerSpeed( 0, 8, 8 );    // 1:15 movement speed
        moonSurfaceLayer->SetSpeed( 0, -250 );

        auto& cloudsLayers = ScrollingBackgroundFactory::Instance()->Get( RESOURCE::SCROLLING_CLOUDS );
        cloudsLayers->SetLayer( 0, RESOURCE::BACKGROUND_CLOUDS1 );
        cloudsLayers->SetLayer( 1, RESOURCE::BACKGROUND_CLOUDS2 );
        cloudsLayers->SetLayerSpeed( 0, 4, 4 );     // 1:7 movement speed
        cloudsLayers->SetLayerSpeed( 1, 1, 1 );     // 1:1 movement speed
        cloudsLayers->SetSpeed( 0, -250 );
    }

    // Load fonts using Factory pattern
    {
        FontFactory::Instance()->Get( RESOURCE::FONT_INFO )->Load( "Assets/Fonts/failed.ttf", 24 );
        FontFactory::Instance()->Get( RESOURCE::FONT_SCORE )->Load( "Assets/Fonts/digital-7_mono.ttf", 32 );
        FontFactory::Instance()->Get( RESOURCE::FONT_SMALL )->Load( "Assets/Fonts/ProFontWindows.ttf", 9 );
        FontFactory::Instance()->Get( RESOURCE::FONT_MENU )->Load( "Assets/Fonts/impact.ttf", 35 );
    }

    // Load sounds using Factory pattern
    {
        SoundFactory::Instance()->Get( RESOURCE::SOUND_INTRO_AMIGADISKFX )->Load( "Assets/Sounds/intro_disksound.ogg" );
        SoundFactory::Instance()->Get( RESOURCE::SOUND_PLAYER_FIRE )->Load( "Assets/Sounds/laser.ogg" );
        SoundFactory::Instance()->Get( RESOURCE::SOUND_ENEMY_FIRE )->Load( "Assets/Sounds/machinegun2.ogg" );
        SoundFactory::Instance()->Get( RESOURCE::SOUND_EXPLOSION1 )->Load( "Assets/Sounds/explosion_1.ogg" );
        SoundFactory::Instance()->Get( RESOURCE::SOUND_EXPLOSION2 )->Load( "Assets/Sounds/explosion_2.ogg" );
    }

    // Preload musics using Factory pattern
    {
        MusicFactory::Instance()->Get( RESOURCE::MUSIC_SPLASH )->Load( "Assets/Musics/cdk_-_Song_Of_Peace.ogg" );
        MusicFactory::Instance()->Get( RESOURCE::MUSIC_INGAME )->Load( "Assets/Musics/Astroboy_Sprung-160.ogg" );
        MusicFactory::Instance()->Get( RESOURCE::MUSIC_GAMEOVER )->Load( "Assets/Musics/Syenta_-_Cytheres_Reves_(Cytheres_Dreams)_2.ogg" );
    }

    // Create texts using Factory pattern
    {
        auto& fontSmall = FontFactory::Instance()->Get( RESOURCE::FONT_SMALL );
        auto& fontInfo = FontFactory::Instance()->Get( RESOURCE::FONT_INFO );
        auto& fontMenu = FontFactory::Instance()->Get( RESOURCE::FONT_MENU );
        TextFactory::Instance()->Get( RESOURCE::TEXT_BETA_BUILD_NOTE )->Create( fontSmall, "Space Attackers : Beta build, not for distribution! // Programming by Mika Luoma-aho <*****@*****.**>", 80, 128, 75, 64 );
        TextFactory::Instance()->Get( RESOURCE::TEXT_STARTGAME )->Create( fontInfo, "< Press space to start a new game or ESC to quit >" );
        TextFactory::Instance()->Get( RESOURCE::TEXT_SPACE_TO_CONTINUE )->Create( fontInfo, "< Press space to continue >" );
        TextFactory::Instance()->Get( RESOURCE::TEXT_ENTER_TO_CONTINUE )->Create( fontInfo, "< Press enter to continue >" );
        TextFactory::Instance()->Get( RESOURCE::TEXT_HIGHSCORES )->Create( fontMenu, "< HI-SCORES >" );
        TextFactory::Instance()->Get( RESOURCE::TEXT_LEVEL_STARTING )->Create( fontMenu, "Get ready for" );
        TextFactory::Instance()->Get( RESOURCE::TEXT_GAMEOVER_SCORE )->Create( fontMenu, "SCORE" );
        TextFactory::Instance()->Get( RESOURCE::TEXT_GAMEOVER_ENTERYOURNAME )->Create( fontMenu, "ENTER YOUR NAME", 255, 220, 100 );
        TextFactory::Instance()->Get( RESOURCE::TEXT_GAMEOVER_NAME )->Create( fontMenu, "" );
        TextFactory::Instance()->Get( RESOURCE::TEXT_GAMEOVER_NAME_PROMPT )->Create( fontMenu, "_" /*«*/ );
    }

    // Create particle effects
    {
        // Create Explosion
        {
            auto& velocityOverTime = InterpolationSetFactory::Instance()->Get( RESOURCE::IS_EXPLOSION_VELOCITY );
            velocityOverTime->AddValue( 0.0f, 20.0f );
            velocityOverTime->AddValue( 0.7f, 10.5f, Math::Interpolation::easeOutCirc<float,float> );

            auto& alphaOverTime = InterpolationSetFactory::Instance()->Get( RESOURCE::IS_EXPLOSION_ALPHA );
            alphaOverTime->AddValue( 0.0f, 1.0f );
            alphaOverTime->AddValue( 1.0f, 0.0f, Math::Interpolation::linearTween<float,float> );

            auto& sizeOverTime = InterpolationSetFactory::Instance()->Get( RESOURCE::IS_EXPLOSION_SIZE );
            sizeOverTime->AddValue( 0.0f, 3.0f );
            sizeOverTime->AddValue( 1.0f, 1.0f, Math::Interpolation::linearTween<float,float> );

            // Flame colors
            // http://kuler.adobe.com/#themeID/177302
            //
            Math::Colors::HSV h1, h2, h3, h4, h5;
            h1 = { 41, 0.84f, 1.0f };
            h2 = { 43, 0.70f, 1.0f };
            h3 = { 63, 0.37f, 0.97f };
            h4 = { 30, 0.85f, 1.0f };
            h5 = { 17, 0.95f, 0.73f };

            auto& colorOverTime = SDLColorInterpolationSetFactory::Instance()->Get( RESOURCE::IS_EXPLOSION_COLOR );
            colorOverTime->AddValue( 0.0f, Math::Colors::HSV2SDLColor(h1) );
            colorOverTime->AddValue( 0.2f, Math::Colors::HSV2SDLColor(h2) );
            colorOverTime->AddValue( 0.4f, Math::Colors::HSV2SDLColor(h3) );
            colorOverTime->AddValue( 0.6f, Math::Colors::HSV2SDLColor(h4) );
            colorOverTime->AddValue( 0.8f, Math::Colors::HSV2SDLColor(h5) );

            // Set parameters
            auto& psExplosion = ExplosionSystemFactory::Instance()->Get( RESOURCE::PS_EXPLOSION );

            psExplosion->Initialize( 500 );
            psExplosion->SetVelocityOverTime( RESOURCE::IS_EXPLOSION_VELOCITY );
            psExplosion->SetAlphaOverTime( RESOURCE::IS_EXPLOSION_ALPHA );
            psExplosion->SetColorOverTime( RESOURCE::IS_EXPLOSION_COLOR );
            psExplosion->SetSizeOverTime( RESOURCE::IS_EXPLOSION_SIZE );
            psExplosion->SetPrimitiveType( 2 );
            psExplosion->SetTrails( false );
        }

        // Create Smoke
        {
            auto& velocityOverTime = InterpolationSetFactory::Instance()->Get( RESOURCE::IS_SMOKE_VELOCITY );
            velocityOverTime->AddValue( 0.0f, 15.0f );
            velocityOverTime->AddValue( 1.0f, 0.0f, Math::Interpolation::linearTween<float,float> );

            auto& alphaOverTime = InterpolationSetFactory::Instance()->Get( RESOURCE::IS_SMOKE_ALPHA );
            alphaOverTime->AddValue( 0.0f, 0.5f );
            alphaOverTime->AddValue( 1.0f, 0.1f, Math::Interpolation::easeInCirc<float,float> );

            auto& sizeOverTime = InterpolationSetFactory::Instance()->Get( RESOURCE::IS_SMOKE_SIZE );
            sizeOverTime->AddValue( 0.0f, 1.0f );
            sizeOverTime->AddValue( 1.0f, 3.0f, Math::Interpolation::linearTween<float,float> );

            // Smoke colors
            // http://kuler.adobe.com/#themeID/1262268
            //
            Math::Colors::HSV h1, h2, h3, h4;
            h1 = { 226, 0.25f, 0.16f };
            h2 = { 235, 0.07f, 0.34f };
            h3 = { 40, 0.08f, 0.41f };
            h4 = { 43, 0.15f, 0.53f };

            auto& colorOverTime = SDLColorInterpolationSetFactory::Instance()->Get( RESOURCE::IS_SMOKE_COLOR );
            colorOverTime->AddValue( 0.0f, Math::Colors::HSV2SDLColor(h1) );
            colorOverTime->AddValue( 0.3f, Math::Colors::HSV2SDLColor(h2) );
            colorOverTime->AddValue( 0.6f, Math::Colors::HSV2SDLColor(h3) );
            colorOverTime->AddValue( 1.0f, Math::Colors::HSV2SDLColor(h4) );

            // Set parameters
            auto& psSmoke = SmokeSystemFactory::Instance()->Get( RESOURCE::PS_SMOKE );

            psSmoke->Initialize( 300 );
            psSmoke->SetVelocityOverTime( RESOURCE::IS_SMOKE_VELOCITY );
            psSmoke->SetAlphaOverTime( RESOURCE::IS_SMOKE_ALPHA );
            psSmoke->SetColorOverTime( RESOURCE::IS_SMOKE_COLOR );
            psSmoke->SetSizeOverTime( RESOURCE::IS_SMOKE_SIZE );
            psSmoke->SetPrimitiveType( 2 );
            psSmoke->SetTrails( false );
        }
    }

    // Create explosion thread to be used in highscore screen
    {
        ExplosionThreadFactory::Instance()->Get( RESOURCE::THREAD_EXPLOSION )->SetExplosion( RESOURCE::PS_EXPLOSION );
    }

    // Create note
    {
        auto& noteText = TextFactory::Instance()->Get( RESOURCE::TEXT_BETA_BUILD_NOTE );
        m_noteImgWidth = noteText->GetSurface()->w;
    }

    // Load scenes into memory and set first scene as running
    {
        unique_ptr<CScene> SplashScene = unique_ptr<SceneSplashScreen>(new SceneSplashScreen);
        unique_ptr<CScene> Level1Scene = unique_ptr<SceneLevel>(new SceneLevel);
        unique_ptr<CScene> GameOverScene = unique_ptr<SceneGameOver>(new SceneGameOver);
        unique_ptr<CScene> HighscoresScene = unique_ptr<SceneHighscores>(new SceneHighscores);
        unique_ptr<CScene> HelpScene = unique_ptr<SceneHelp>(new SceneHelp);

        // Add scenes (order is also the render order!)
        AddScene( SCENE_0_Intro, SplashScene );
        AddScene( SCENE_1_Game, Level1Scene );
        AddScene( SCENE_2_GameOver, GameOverScene );
        AddScene( SCENE_3_Highscores, HighscoresScene );
        AddScene( SCENE_4_Help, HelpScene );
    }

    // Load and run the first scene
    //#ifdef DEBUG_SCENE1
    //LoadAndRunScene( SCENE_1_Game );
    //SetState( (int)STATE::GAME );
    auto& properties = CSingleton<CProperties>::Instance();
    #ifdef DEBUG_GAMEOVER
    properties->Property( "Player", "Name" ) = (std::string)"";
    properties->Property( "Player", "Score" ) = static_cast<int>(1234567);
    properties->Property( "Player", "Fired" ) = static_cast<int>(1000);
    properties->Property( "Player", "Kills" ) = static_cast<int>(20);
    properties->Property( "Player", "Accuracy" ) = static_cast<int>(98);
    properties->Property( "Player", "Level" ) = static_cast<int>(27);
    LoadAndRunScene( SCENE_2_GameOver );
    SetState( (int)STATE::GAME_OVER );
    #else
    properties->Property( "Player", "Name" ) = (std::string)"";
    LoadAndRunScene( SCENE_0_Intro );
    SetState( (int)STATE::SPLASH_SCREEN );
    #endif

    // Default to 60fps
    SDL_initFramerate( &m_fpsManager );
    SDL_setFramerate( &m_fpsManager, 60 );

    // Initialize state handlers
    InitHandlers();
}