public void StartTrainBoxApp()
        {

            Level.PrepareEntityTypes();

            bool quit = false;

            TextureMan.LoadTextures();
            TextureMan.CreateShadows();

            bufferSpr = new Sprite();

            buffer = new RenderTexture(320, 120);
            buffer.Clear(Color.Black);

            menu.Active = true;
            menu.State = Menu.MenuState.Intro;
            menu.CounterReset();
            menu.LoadLevelInfo();

            while (true)
            {
                if (fullScreen)
                {
                    screenSizeX = 1366;
                    screenSizeY = 768;                    
                }
                else
                {
                    screenSizeX = 960;
                    screenSizeY = 540;                    
                }

                if (fullScreen) window = new RenderWindow(new VideoMode(screenSizeX, screenSizeY), 
                    "Super Starbox", Styles.Fullscreen);  
                else window = new RenderWindow(new VideoMode(screenSizeX, screenSizeY), 
                    "Super Starbox", Styles.Titlebar);
                    
                window.SetMouseCursorVisible(!fullScreen);

                window.SetVisible(true);
                window.Closed += new EventHandler(OnClosed);
                window.SetFramerateLimit(60);

                window.LostFocus += new EventHandler(OnLostFocus);
                window.GainedFocus += new EventHandler(OnGainedFocus);

                bool editorButtonTrigger = false;

                SoundMan.PlayMusic();

                while (true)
                {

                    buffer.Clear(Color.Black);

                    if (!menu.Active)
                    {
                        level.DrawLevel(buffer);
                    }
                    
                    
                    if (fadeOut != 0)
                    {
                        RectangleShape rect = new RectangleShape();

                        rect.Position = new Vector2f(0,0);
                        rect.Size = new Vector2f(320, 120);
                        rect.FillColor = new Color(0, 0, 0, (byte)fadeOut);

                        buffer.Draw(rect);
                    }

                    if (menu.Active) menu.Draw(buffer);
                    if (editor.Active) editor.Draw(buffer);

                    buffer.Display();

                    bufferSpr.Texture = buffer.Texture;
                    bufferSpr.Scale = new Vector2f((screenSizeX / 320f) * screenScale, (screenSizeY / 120f) * screenScale);
                    
                    bufferSpr.Origin = new Vector2f(160, 60);
                    bufferSpr.Position = new Vector2f(screenSizeX/2, screenSizeY/2);

                    if (screenShake > 0)
                    {
                        bufferSpr.Position = new Vector2f(bufferSpr.Position.X + (float)new Random().Next(-200,200)/75, 
                                                          bufferSpr.Position.Y + (float)new Random().Next(-200,200)/75);
                    }

                    if (gameState == GameState.ResetFadeOut)
                    {
                        
                        bufferSpr.Rotation = gameStateC / 2;

                        screenScale = 1f + (float)gameStateC / 50f;
              
                    }

                    if (gameState == GameState.LevelFinished)
                    {

                        bufferSpr.Rotation = gameStateC / 2;

                        screenScale = 1f + (float)gameStateC / 25f;

                    }
                    
                    if (gameState == GameState.ResetFadeIn)
                    {

                        bufferSpr.Rotation = (50-gameStateC) / 2;

                        screenScale = 1f + (float)(50 - gameStateC) / 50f;

                    }                    

                    if (gameState == GameState.GamePlay || menu.Active)
                    {
                        screenScale = 1;
                        bufferSpr.Rotation = 0;
                    }

                    window.DispatchEvents();
                    window.Clear(Color.Black);
                    window.Draw(bufferSpr);
                    window.Display();


                    if (Keyboard.IsKeyPressed(Keyboard.Key.F4))
                    {
                        fullScreen = !fullScreen;
                        break;
                    }

                    if (Keyboard.IsKeyPressed(Keyboard.Key.F10) && false)
                    {
                        if (!menu.Active)
                        if (!editorButtonTrigger)
                        {
                            editor.Active = !editor.Active;
                            if (editor.Active)
                            {
                                editor.LevelName = levelName;
                                level.ResetLevel();
                                level.ResetScrollBounds();
                                CollisionMan.Entities = level.GetEntities();
                                EntityFinder.Entities = level.GetEntities();
                                editor.Level = level;
                            }
                            else
                            {
                                levelName = editor.LevelName;
                                level = editor.Level;
                                level.FindScrollBounds();
                                gameState = GameState.StartLevel;
                            }
                        }
                        editorButtonTrigger = true;
                    }
                    else editorButtonTrigger = false;

                    if (!editor.Active && !menu.Active)
                    {
                        GameLoop();
                    }

                    if (editor.Active) if (windowHasFocus) editor.Loop(window);
                    if (menu.Active)
                    {
                        if (windowHasFocus) menu.Loop(window);

                        if (menu.State == Menu.MenuState.Quit)
                        {
                            quit = true;
                            break;
                        }

                        if (menu.State == Menu.MenuState.StartLevel)
                        {
                            levelName = menu.LevelName;

                            menu.Active = false;
                            level.LoadLevel(levelName);

                            gameStateC = 0;
                            gameState = GameState.ResetFadeIn;
                            fadeOut = 255;

                            CollisionMan.Entities = level.GetEntities();
                            EntityFinder.Entities = level.GetEntities();
                        }
                    }
                }

                window.Dispose();
                if (quit) break;
            }

            menu.SaveLevelInfo();
        }