コード例 #1
0
        public static int Main()
        {
            //Opens a new Graphics Window
            SwinGame.OpenGraphicsWindow("Battle Ships", 800, 600);

            //Load Resources
            GameResources.LoadResources();

            SwinGame.PlayMusic(GameResources.GameMusic("Background"));

            //Game Loop
            do
            {
                GameController.HandleUserInput();
                GameController.DrawScreen();
            } while (!(SwinGame.WindowCloseRequested() == true | GameController.CurrentState == GameState.Quitting));

            SwinGame.StopMusic();

            //Free Resources and Close Audio, to end the program.
            try
            {
                GameResources.FreeResources();
            }
            catch (Exception e)
            {
                System.Console.WriteLine("The following exception is due to .NET 4+");
                System.Console.WriteLine(e.Message);
                return(1);
            }

            return(0);
        }
コード例 #2
0
        public static void Main()
        {
            //Opens a new Graphics Window("Battleships", 800, 600);
            SwinGame.OpenGraphicsWindow("Battleships", 800, 600);

            //Load Resources
            GameResources.LoadResources();

            SwinGame.PlayMusic(GameResources.GameMusic("Background"));

            //Game Loop
            do
            {
                GameController.HandleUserInput();
                GameController.DrawScreen();
                if (SwinGame.KeyTyped(KeyCode.vk_F10))
                {
                    SwinGame.ToggleFullScreen();
                }
            } while (!(SwinGame.WindowCloseRequested() == true | GameController.CurrentState == GameState.Quitting));

            SwinGame.StopMusic();

            //Free Resources and Close Audio, to end the program.
            GameResources.FreeResources();
        }
コード例 #3
0
        /// <summary>
        /// The game menu was clicked, perform the button's action.
        /// </summary>
        /// <param name="button">the button pressed</param>
        private static void PerformGameMenuAction(int button)
        {
            switch (button)
            {
            case GAME_MENU_RETURN_BUTTON: {
                GameController.EndCurrentState();
                break;
            }

            case GAME_MENU_SURRENDER_BUTTON: {
                // End game menu
                GameController.EndCurrentState();
                // End game
                GameController.EndCurrentState();
                break;
            }

            case GAME_MENU_QUIT_BUTTON: {
                GameController.AddNewState(GameState.Quitting);
                break;
            }

            case GAME_MENU_MUTE_BUTTON:
            {
                //GameController.AddNewState(GameState.Quitting);
                if (Extentions.MusicPlaying == false)
                {
                    SwinGame.PlayMusic(GameResources.GameMusic("Background"));
                    Extentions.MusicPlaying     = true;
                    Extentions.MusicPlayingWord = "MUTE";
                    DrawButtons(GAME_MENU);
                }
                else if (Extentions.MusicPlaying == true)
                {
                    SwinGame.StopMusic();
                    Extentions.MusicPlaying     = false;
                    Extentions.MusicPlayingWord = "UNMUTE";
                    DrawButtons(GAME_MENU);
                    SwinGame.RefreshScreen();
                }
                GameController.EndCurrentState();
                break;
            }
            }
        }