Esempio n. 1
0
        static void Main(string[] args)
        {
            settings.AntialiasingLevel = 8;

            MainWindow = new RenderWindow(new VideoMode(WidthWindow, HeightWindow), "Story of one Cube", Styles.None, settings);
            MainWindow.SetVerticalSyncEnabled(true);
            MainWindow.Closed             += MainWindow_Closed;
            MainWindow.KeyPressed         += MainWindow_KeyPressed;
            MainWindow.KeyReleased        += MainWindow_KeyReleased;
            MainWindow.MouseMoved         += MainWindow_MouseMoved;
            MainWindow.MouseButtonPressed += MainWindow_MouseButtonPressed;

            MainWindow.SetVerticalSyncEnabled(true);

            CharacterMovesAnimation.Init();
            DeadScreen.Init(MainWindow);
            WinScreen.Init(MainWindow);
            MainMenu.Init(MainWindow);
            Background.Init(MainWindow);
            Sounds.Init();
            Musics.Init();
            Inventory.Init();
            Interface.Init();
            LevelChoosePage.Init(MainWindow);

            levelNow = new Level1();

            Background.Set(0);

            musicNow = Musics.MainMenu;
            musicNow.Play();

            while (MainWindow.IsOpen)
            {
                MainWindow.Clear();

                Background.Draw(MainWindow);

                if (Background.IsLoaded)
                {
                    if (windowModeNow == WindowMode.Menu)
                    {
                        MainMenu.DrawAndUpdate(MainWindow);
                    }

                    if (windowModeNow == WindowMode.LevelsChoose)
                    {
                        LevelChoosePage.DrawAndUpdate(MainWindow);
                    }

                    if (windowModeNow == WindowMode.Game)
                    {
                        levelNow.Update(MainWindow);
                        levelNow.Draw(MainWindow);
                    }

                    if (windowModeNow == WindowMode.Dead)
                    {
                        levelNow.Draw(MainWindow);
                        DeadScreen.DrawAndUpdate(MainWindow);
                    }

                    if (windowModeNow == WindowMode.Pause)
                    {
                        levelNow.Draw(MainWindow);
                        DeadScreen.DrawAndUpdate(MainWindow);
                    }

                    if (windowModeNow == WindowMode.Win)
                    {
                        levelNow.Draw(MainWindow);
                        WinScreen.DrawAndUpdate(MainWindow);
                    }

                    MainWindow.DispatchEvents();
                }

                MainWindow.Display();
            }
        }