private void StopGame()
        {
            if (GamestateManager.Instance.GamePhase == GamePhase.Ending)
            {
                ScoreManager.AddScore(Menu.PlayerName, GamestateManager.Instance.Points);
                GamestateManager.Instance.DeleteSave();
            }
            else
            {
                GamestateManager.Instance.Save();
            }

            HUD.Dispose();
            HUD = null;
            GamestateManager.Instance.Clear();
            CollisionHandler.Clear();

            MusicManager.Instance.StopMusic();

            Menu.ShowMenu();
        }
        public void Loop()
        {
            DateTime time1 = DateTime.Now;
            DateTime time2;

            while (Window.IsOpen && !ShouldQuit)
            {
                try
                {
                    time2 = DateTime.Now;
                    float deltaTime = (time2.Ticks - time1.Ticks) / 10000000f;

                    Tick(deltaTime);
                    Render();

                    time1 = time2;
                }
                catch (Exception e)
                {
                    throw new InvalidOperationException("Application cannot be run, please reinstall application", e);
                }
            }

            if (!Window.IsOpen && GamestateManager.Instance.GamePhase != GamePhase.NotStarted)
            {
                GamestateManager.Instance.Save();

                HUD.Dispose();
                HUD = null;

                GamestateManager.Instance.Clear();

                CollisionHandler.Clear();

                MusicManager.Instance.StopMusic();
            }
        }