public static int Main() { //Opens a new Graphics Window SwinGame.OpenGraphicsWindow("Battle Ships", 800, 600); //Load Resources GameResources.LoadResources(); //Removed as was making play music method in utility functions obselete //SwinGame.PlayMusic(GameResources.GameMusic("Background")); //Game Loop - added Play music to loop through different tracks do { GameController.HandleUserInput(); GameController.DrawScreen(); UtilityFunctions.PlayMusic(); } while (!(SwinGame.WindowCloseRequested() == true | GameController.CurrentState == GameState.Quitting)); UtilityFunctions.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); }
// The game menu was clicked, perform the button's action. // Parameter: button - The button pressed private static void PerformGameMenuAction(int button) { switch (button) { case GAME_MENU_RETURN_BUTTON: GameController.EndCurrentState(); break; case GAME_MENU_SURRENDER_BUTTON: GameController.EndCurrentState(); // end game menu GameController.EndCurrentState(); // end game break; case GAME_MENU_QUIT_BUTTON: GameController.AddNewState(GameState.Quitting); break; case GAME_MENU_MUTE_MUSIC_ACTION: if (Audio.MusicPlaying()) { UtilityFunctions.StopMusic(); } else { UtilityFunctions.PlayMusic(); } break; case GAME_MENU_MUTE_SFX_ACTION: if (UtilityFunctions.SFX_ACTIVE) { UtilityFunctions.RemoveSFX(); } else { UtilityFunctions.LoadSFX(); } break; } }