/// <summary>
    /// The Resources Class stores all of the Games Media Resources, such as Images, Fonts
    /// Sounds, Music.
    /// </summary>

    public static void LoadResources()
    {
        int width  = 0;
        int height = 0;

        width  = SwinGame.ScreenWidth();
        height = SwinGame.ScreenHeight();

        SwinGame.ChangeScreenSize(800, 600);

        ShowLoadingScreen();

        ShowMessage("Loading fonts...", 0);
        LoadFonts();
        SwinGame.Delay(100);

        ShowMessage("Loading images...", 1);
        LoadImages();
        SwinGame.Delay(100);

        ShowMessage("Loading sounds...", 2);
        LoadSounds();
        SwinGame.Delay(100);

        ShowMessage("Loading music...", 3);
        LoadMusic();
        SwinGame.Delay(100);

        SwinGame.Delay(100);
        ShowMessage("Game loaded...", 5);
        SwinGame.Delay(100);
        EndLoadingScreen(width, height);
    }
Example #2
0
    /// <summary>
    /// The Resources Class stores all of the Games Media Resources, such as Images, Fonts
    /// Sounds, Music.
    /// </summary>
    public static void LoadResources()
    {
        int width = 0;
        int height = 0;

        width = SwinGame.ScreenWidth();
        height = SwinGame.ScreenHeight();

        SwinGame.ChangeScreenSize(800, 600);

        ShowLoadingScreen();

        ShowMessage(0);
        LoadFonts();
        SwinGame.Delay(100);

        ShowMessage(1);
        LoadImages();
        SwinGame.Delay(100);

        ShowMessage(2);
        LoadSounds();
        SwinGame.Delay(100);

        ShowMessage(3);
        LoadMusic();
        SwinGame.Delay(100);

        SwinGame.Delay(100);
        ShowMessage(5);
        SwinGame.Delay(100);
        EndLoadingScreen(width, height);
    }
Example #3
0
    /// <summary>
    /// The Resources Class stores all of the Games Media Resources, such as Images, Fonts
    /// Sounds, Music.
    /// </summary>

    public static void LoadResources()
    {
        // Set up window
        int width  = 0;
        int height = 0;

        SwinGame.ChangeScreenSize(800, 600);

        // Display loading screen
        ShowLoadingScreen();

        ShowMessage("Loading fonts...", 0);
        LoadFonts();
        SwinGame.Delay((uint)100);

        ShowMessage("Loading images...", 1);
        LoadImages();
        SwinGame.Delay((uint)100);

        ShowMessage("Loading sounds...", 2);
        LoadSounds();
        SwinGame.Delay((uint)100);

        ShowMessage("Loading music...", 3);
        LoadMusic();
        SwinGame.Delay((uint)100);

        SwinGame.Delay((uint)100);
        ShowMessage("Game loaded...", 5);
        SwinGame.Delay((uint)100);
        EndLoadingScreen(width, height);
    }
Example #4
0
 /// <summary>
 /// Ends the loading screen.
 /// </summary>
 /// <param name="width">Width.</param>
 /// <param name="height">Height.</param>
 private static void EndLoadingScreen(int width, int height)
 {
     SwinGame.ProcessEvents();
     SwinGame.Delay(500);
     SwinGame.ClearScreen();
     SwinGame.RefreshScreen();
     FreeCurrentResource();
     SwinGame.ChangeScreenSize(width, height);
 }
Example #5
0
 /// <summary>
 /// Handle the end loading screen
 /// </summary>
 /// <param name="width"></param>
 /// <param name="height"></param>
 private static void EndLoadingScreen(int width, int height)
 {
     SwinGame.ProcessEvents();
     SwinGame.Delay(500);
     SwinGame.ClearScreen();
     SwinGame.RefreshScreen();
     SwinGame.FreeFont(_LoadingFont);
     SwinGame.FreeBitmap(_Background);
     SwinGame.FreeBitmap(_LoaderEmpty);
     SwinGame.FreeBitmap(_LoaderFull);
     Audio.FreeSoundEffect(_StartSound);
     SwinGame.ChangeScreenSize(width, height);
 }
Example #6
0
        /// <summary>
        /// End the loading screen and free its resources
        /// </summary>
        /// <param name="width">Screen width</param>
        /// <param name="height">Screen height</param>

        private static void EndLoadingScreen(int width, int height)
        {
            SwinGame.ProcessEvents();
            SwinGame.Delay(500);
            SwinGame.ClearScreen();
            SwinGame.RefreshScreen();
            SwinGame.FreeFont(_LoadingFont);
            SwinGame.FreeBitmap(_Background);
            SwinGame.FreeBitmap(_Animation);
            SwinGame.FreeBitmap(_LoaderEmpty);
            SwinGame.FreeBitmap(_LoaderFull);
            //Audio.FreeSoundEffect(_StartSound); // TODO: Crashes on windows and linux SwinGame Library error
            SwinGame.ChangeScreenSize(width, height);
        }
Example #7
0
 /// <summary>
 /// closes loading screen and sets up main game to run
 /// </summary>
 /// <param name="width"></param>
 /// <param name="height"></param>
 private static void EndLoadingScreen(int width, int height)
 {
     SwinGame.ProcessEvents();
     SwinGame.Delay(500);
     SwinGame.ClearScreen();
     SwinGame.RefreshScreen();
     SwinGame.FreeFont(_LoadingFont);
     SwinGame.FreeBitmap(_Background);
     SwinGame.FreeBitmap(_Animation);
     SwinGame.FreeBitmap(_LoaderEmpty);
     SwinGame.FreeBitmap(_LoaderFull);
     // Audio.FreeSoundEffect(_StartSound); // SwinGame library crashes when freeing sound effects for some reason.
     SwinGame.ChangeScreenSize(width, height);
 }
Example #8
0
        private static void EndLoadingScreen(int width, int height)
        {
            SwinGame.ProcessEvents();
            SwinGame.Delay(500);
            SwinGame.ClearScreen();
            SwinGame.RefreshScreen();
            SwinGame.FreeFont(_LoadingFont);
            SwinGame.FreeBitmap(_Background);
            SwinGame.FreeBitmap(_Animation);
            SwinGame.FreeBitmap(_LoaderEmpty);
            SwinGame.FreeBitmap(_LoaderFull);

            // TODO: Figure out why FreeSoundEffect throws a "System.AccessViolationException"
            //Audio.FreeSoundEffect(_StartSound);
            SwinGame.ChangeScreenSize(width, height);
        }
Example #9
0
        public void Init()
        {
            searchStrategy = SearchStrategyFactory.Create(Filename, Method, popSize, mutRate, fitMulti, diversity, elite, deepeningInc);
            inputHandler   = new InputHandler(searchStrategy, this);

            //resize window so it looks better
            SwinGame.ChangeScreenSize(searchStrategy.fMap.Width * searchStrategy.gridW, searchStrategy.fMap.Height * searchStrategy.gridH + 155);

            if (forceStart)
            {
                searchStrategy.Start();
                forceStart = false;
            }

            PathSize = 0;
        }
Example #10
0
        //Clears the bitmaps that were loaded to display background images
        private static void EndLoadingScreen(int width, int height)
        {
            SwinGame.ProcessEvents();
            SwinGame.Delay(500);
            SwinGame.ClearScreen();
            SwinGame.RefreshScreen();
            SwinGame.FreeFont(_LoadingFont);
            SwinGame.FreeBitmap(_Background);
            SwinGame.FreeBitmap(_Animation);
            SwinGame.FreeBitmap(_LoaderEmpty);
            SwinGame.FreeBitmap(_LoaderFull);
            //SwinGame.FreeSoundEffect(_StartSound);


            //Resets the screen size if the loading screen to width/height variables, instead of set 800x600 for loading screen.
            SwinGame.ChangeScreenSize(width, height);
        }
Example #11
0
    // Clear loading screen
    private static void EndLoadingScreen(int width, int height)
    {
        SwinGame.ProcessEvents();
        SwinGame.Delay(500);

        SwinGame.ClearScreen();
        SwinGame.RefreshScreen();
        SwinGame.FreeFont(_loadingFont);
        SwinGame.FreeBitmap(_background);
        SwinGame.FreeBitmap(_animation);
        SwinGame.FreeBitmap(_loaderEmpty);
        SwinGame.FreeBitmap(_loaderFull);

        //TODO(Xavier): This causes the game to crash
        //Audio.FreeSoundEffect (_StartSound);
        SwinGame.ChangeScreenSize(width, height);
    }
Example #12
0
    private static void EndLoadingScreen(int width, int height)
    {
        SwinGame.ProcessEvents();
        const int processDelay = 500;

        SwinGame.Delay(processDelay);
        SwinGame.ClearScreen();
        SwinGame.RefreshScreen();
        SwinGame.FreeFont(_LoadingFont);
        SwinGame.FreeBitmap(_Background);
        SwinGame.FreeBitmap(_Animation);
        SwinGame.FreeBitmap(_LoaderEmpty);
        SwinGame.FreeBitmap(_LoaderFull);
        // SV: commented out as this causes a memory access violation.
        //Audio.FreeSoundEffect(_StartSound);
        SwinGame.ChangeScreenSize(width, height);
    }
Example #13
0
    /// <summary>
    /// The Resources Class stores all of the Games Media Resources, such as Images, Fonts
    /// Sounds, Music.
    /// </summary>

    public static void LoadResources()
    {
        int width  = 0;
        int height = 0;

        const int WINDOW_WIDTH  = 800;
        const int WINDOW_HEIGHT = 600;

        const int DELAY = 100;

        width  = SwinGame.ScreenWidth();
        height = SwinGame.ScreenHeight();

        SwinGame.ChangeScreenSize(WINDOW_WIDTH, WINDOW_HEIGHT);

        ShowLoadingScreen();

        ShowMessage("Loading fonts...", 0, false);
        LoadFonts();
        SwinGame.Delay(DELAY);

        ShowMessage("Loading images...", 1, false);
        LoadImages();
        SwinGame.Delay(DELAY);

        ShowMessage("Loading sounds...", 2, false);
        LoadSounds();
        SwinGame.Delay(DELAY);

        ShowMessage("Loading music...", 3, false);
        LoadMusic();
        SwinGame.Delay(DELAY);

        SwinGame.Delay(DELAY);
        ShowMessage("Game loaded...", 5, true);
        SwinGame.Delay(DELAY);

        // SV: uncommented this, and commented out the line
        // in the method that was causing the memory access violation.
        EndLoadingScreen(width, height);
    }
    public static void 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();
            //Changging Screen Resoultion
            if (SwinGame.KeyTyped(KeyCode.vk_f))
            {
                SwinGame.ChangeScreenSize(1920, 1080);
            }
            else if (SwinGame.KeyTyped(KeyCode.vk_c))
            {
                SwinGame.ChangeScreenSize(800, 600);
            }
            //Pausing and Resuming Music/Sound
            if (SwinGame.KeyTyped(KeyCode.vk_m))
            {
                SwinGame.PauseMusic();
            }
            else if (SwinGame.KeyTyped(KeyCode.vk_p))
            {
                SwinGame.ResumeMusic();
            }
        } while (!(SwinGame.WindowCloseRequested() == true | GameController.CurrentState == GameState.Quitting));

        SwinGame.StopMusic();

        //Free Resources and Close Audio, to end the program.
        GameResources.FreeResources();
    }