예제 #1
0
        /// <summary>
        /// Draws the background for the current state of the game
        /// </summary>

        public void DrawBackground(GameController con)
        {
            switch (con.CurrentState)
            {
            case GameState.ViewingMainMenu:
            case GameState.ViewingGameMenu:
            case GameState.AlteringSettings:
            case GameState.ViewingHighScores:
                SwinGame.DrawBitmap(con._resources.GameImage("Menu"), 0, 0);
                break;

            case GameState.Discovering:
            case GameState.EndingGame:
                SwinGame.DrawBitmap(con._resources.GameImage("Discovery"), 0, 0);
                break;

            case GameState.Deploying:
                SwinGame.DrawBitmap(con._resources.GameImage("Deploy"), 0, 0);
                break;

            default:
                SwinGame.ClearScreen();
                break;
            }

            SwinGame.DrawFramerate(675, 585);
        }
예제 #2
0
        /// <summary>
        /// Draws the background for the current state of the game
        /// </summary>

        public static void DrawBackground()
        {
            switch (GameController.CurrentState)
            {
            case GameState.ViewingMainMenu:
            case GameState.ViewingGameMenu:
            case GameState.AlteringSettings:
            case GameState.ViewingHighScores:
                SwinGame.DrawBitmap(GameResources.GameImage("Menu"), 0, 0);
                SwinGame.DrawText("Difficulty: " + GameController.getAiDifficultyText(), Color.Yellow, 600, 30);
                break;

            case GameState.Discovering:
            case GameState.EndingGame:
                SwinGame.DrawBitmap(GameResources.GameImage("Discovery"), 0, 0);
                break;

            case GameState.Deploying:
                SwinGame.DrawBitmap(GameResources.GameImage("Deploy"), 0, 0);
                break;

            default:
                SwinGame.ClearScreen();
                break;
            }

            SwinGame.DrawFramerate(675, 585, GameResources.GameFont("CourierSmall"));
        }
예제 #3
0
    // <summary>
    // Draws the background for the current state of the game
    // </summary>
    public static void DrawBackground()
    {
        switch (GameController.CurrentState)
        {
        case var @case when @case == GameState.ViewingMainMenu:
        case var case1 when case1 == GameState.ViewingGameMenu:
        case var case2 when case2 == GameState.AlteringSettings:
        case var case3 when case3 == GameState.ViewingHighScores:
        {
            SwinGame.DrawBitmap(GameResources.GameImage("Menu"), 0, 0);
            break;
        }

        case var case4 when case4 == GameState.Discovering:
        case var case5 when case5 == GameState.EndingGame:
        {
            SwinGame.DrawBitmap(GameResources.GameImage("Discovery"), 0, 0);
            break;
        }

        case var case6 when case6 == GameState.Deploying:
        {
            SwinGame.DrawBitmap(GameResources.GameImage("Deploy"), 0, 0);
            break;
        }

        default:
        {
            SwinGame.ClearScreen();
            break;
        }
        }

        SwinGame.DrawFramerate(675, 585);
    }
예제 #4
0
        public static void Main()
        {
            //Open the game window
            SwinGame.OpenGraphicsWindow("DuckSteroids", 800, 600);
            SwinGame.ShowSwinGameSplashScreen();

            Screen screen = new Screen();

            //Run the game loop
            while (false == SwinGame.WindowCloseRequested())
            {
                //Fetch the next batch of UI interaction
                SwinGame.ProcessEvents();


                screen.ProcessInput();
                if (screen.IsQuit)
                {
                    break;
                }
                screen.Update();


                //Clear the screen and draw the framerate
                SwinGame.ClearScreen(Color.White);
                SwinGame.DrawFramerate(0, 0);


                //Draw onto the screen
                screen.Draw();

                SwinGame.RefreshScreen(60);
            }
        }
예제 #5
0
        public static void Main()
        {
            //Open the game window
            SwinGame.OpenGraphicsWindow("Space War", 800, 600);
            SwinGame.ShowSwinGameSplashScreen();
            //Load Resources
            GameResources.LoadResources();

            //Run the game loop
            do
            {
                //Fetch the next batch of UI interaction
                SwinGame.ProcessEvents();

                //Clear the screen and draw the framerate
                SwinGame.ClearScreen(Color.White);
                GameController.UserInput();
                GameController.Draw();
                SwinGame.DrawFramerate(615, 590);

                //Draw onto the screen
                SwinGame.RefreshScreen(60);
            } while (!(SwinGame.WindowCloseRequested() == true || GameController.CurrentState == GameState.Quiting));

            SwinGame.StopMusic();

            //Free Resources and Close Audio, to end the program.
            GameResources.FreeResources();
        }
예제 #6
0
    /// <summary>
    /// Draws the background for the current state of the game
    /// </summary>

    public static void DrawBackground()
    {
        switch (GameController.CurrentState)
        {
        ///Loading different menus
        ///Main menu
        case GameState.ViewingMainMenu:
        ///Game menu
        case GameState.ViewingGameMenu:
        ///Settings menu
        case GameState.AlteringSettings:
        ///High scores menu
        case GameState.ViewingHighScores:
            SwinGame.DrawBitmap(GameResources.GameImage("Menu"), 0, 0);
            break;

        case GameState.Discovering:
        ///End game screen
        case GameState.EndingGame:
            SwinGame.DrawBitmap(GameResources.GameImage("Discovery"), 0, 0);
            break;

        case GameState.Deploying:
            SwinGame.DrawBitmap(GameResources.GameImage("Deploy"), 0, 0);
            break;

        default:
            SwinGame.ClearScreen();
            break;
        }
        ///Draw framerate in CourierSmall
        SwinGame.DrawFramerate(675, 585, GameResources.GameFont("CourierSmall"));
    }
예제 #7
0
파일: MyGame.cs 프로젝트: 7682840/lander
        public static void Main()
        {
            //Open the game window
            SwinGame.OpenGraphicsWindow("GameMain", 1600, 900);
            SwinGame.ShowSwinGameSplashScreen();

            Lander l = new Lander((SwinGame.ScreenWidth() / 2) - (30 / 2), 10); // 30 is lander bitmap width hardcoded

            //Run the game loop
            while (false == SwinGame.WindowCloseRequested())
            {
                //Fetch the next batch of UI interaction
                SwinGame.ProcessEvents();

                //Clear the screen and draw the framerate
                SwinGame.ClearScreen(Color.White);
                SwinGame.DrawFramerate(0, 0);

                l.CalculatePosition(); // Move the lander
                l.DrawLander();        // Draw the lander

                //Draw onto the screen
                SwinGame.RefreshScreen(60);
            }
            SwinGame.ReleaseAllResources();
            SwinGame.ReleaseAllSprites();
        }
예제 #8
0
        public static void Main()
        {
            //Initialize objects
            Planner myPlanner = new Planner();



            //Open the game window
            SwinGame.OpenGraphicsWindow("GameMain", 800, 600);
            SwinGame.ShowSwinGameSplashScreen();



            //Run the game loop
            while (false == SwinGame.WindowCloseRequested())
            {
                //Fetch the next batch of UI interaction
                SwinGame.ProcessEvents();
                //


                //Clear the screen and draw the framerate
                SwinGame.ClearScreen(Color.White);
                SwinGame.DrawFramerate(0, 0);

                //Draw onto the screen

                myPlanner.Draw();
                myPlanner.SaveButton("C:\\Users\\Daisy\\Desktop\\test.txt");
                myPlanner.LoadButton("C:\\Users\\Daisy\\Desktop\\test.txt");
                SwinGame.RefreshScreen(60);
            }
        }
예제 #9
0
        public static void Main()
        {
            int width  = 800;
            int height = 600;

            Rectangle boundary = new Rectangle(width / 2, height / 2, width / 2, height / 2);
            QuadTree  qt       = new QuadTree(boundary);

            for (int i = 0; i < 1000; i++)
            {
                Point pt = new Point(SwinGame.Rnd(width), SwinGame.Rnd(height));
                qt.Insert(pt);
            }

            SwinGame.OpenGraphicsWindow("GameMain", width, height);
            SwinGame.ShowSwinGameSplashScreen();
            while (false == SwinGame.WindowCloseRequested())
            {
                SwinGame.ProcessEvents();
                SwinGame.ClearScreen(Color.White);

                qt.DrawPoints();

                SwinGame.DrawFramerate(0, 0);
                SwinGame.RefreshScreen(60);
            }
        }
예제 #10
0
        public static void DrawGame()
        {
            SwinGame.ClearScreen(BG_CLR);

            switch (_state.Peek())
            {
            case GameState.MainMenu:
                DrawMainMenu();
                break;

            case GameState.Options:
                DrawOptionsMenu();
                break;

            case GameState.InGame:
                DrawSnake(_grid.SnakeObj);
                break;

            case GameState.GameOver:
                DrawGameOver();
                break;

            case GameState.Quitting:
                break;
            }


            SwinGame.DrawFramerate(0, 0);
            SwinGame.RefreshScreen(60);
        }
예제 #11
0
        /// <summary>
        /// Draws the background for the current state of the game
        /// </summary>
        public static void DrawBackground()
        {
            switch (GameController.Instance.CurrentState)
            {
            case GameState.ViewingMainMenu:
            case GameState.ViewingGameMenu:
            case GameState.AlteringSettings:
            case GameState.ViewingHighScores:
            {
                SwinGame.DrawBitmap(GameResources.Instance.GameImage("Menu"), 0, 0);
                break;
            }

            case GameState.Discovering:
            case GameState.EndingGame:
            {
                SwinGame.DrawBitmap(GameResources.Instance.GameImage("Discovery"), 0, 0);
                break;
            }

            case GameState.Deploying:
            {
                SwinGame.DrawBitmap(GameResources.Instance.GameImage("Deploy"), 0, 0);
                break;
            }

            default:
            {
                SwinGame.ClearScreen();
                break;
            }
            }

            SwinGame.DrawFramerate(620, 585);
        }
예제 #12
0
        public static void Main()
        {
            Shape myShape = new Shape();

            //Open the game window
            SwinGame.OpenGraphicsWindow("GameMain", 800, 600);
            SwinGame.ShowSwinGameSplashScreen();

            //Run the game loop
            while (SwinGame.WindowCloseRequested() == false)
            {
                //Fetch the next batch of UI interaction
                SwinGame.ProcessEvents();

                //Clear the screen and draw the framerate
                SwinGame.ClearScreen(Color.White);
                myShape.Draw();
                if (SwinGame.MouseClicked(MouseButton.LeftButton))
                {
                    myShape.X = SwinGame.MouseX();
                    myShape.Y = SwinGame.MouseY();
                }
                if (myShape.isAt(SwinGame.MousePosition()) && SwinGame.KeyTyped(KeyCode.vk_SPACE))
                {
                    myShape.Color = SwinGame.RandomRGBColor(255);
                }
                SwinGame.DrawFramerate(0, 0);


                //Draw onto the screen
                SwinGame.RefreshScreen(60);
            }
        }
예제 #13
0
        /// <summary>
        ///     ''' Draws the background for the current state of the game
        ///     ''' </summary>
        public static void DrawBackground()
        {
            switch (CurrentState)
            {
            case object _ when GameState.ViewingMainMenu:
            case object _ when GameState.ViewingGameMenu:
            case object _ when GameState.AlteringSettings:
            case object _ when GameState.ViewingHighScores:
            {
                SwinGame.DrawBitmap(GameImage("Menu"), 0, 0);
                break;
            }

            case object _ when GameState.Discovering:
            case object _ when GameState.EndingGame:
            {
                SwinGame.DrawBitmap(GameImage("Discovery"), 0, 0);
                break;
            }

            case object _ when GameState.Deploying:
            {
                SwinGame.DrawBitmap(GameImage("Deploy"), 0, 0);
                break;
            }

            default:
            {
                SwinGame.ClearScreen();
                break;
            }
            }

            SwinGame.DrawFramerate(675, 585);
        }
예제 #14
0
    /// <summary>
    /// Draws the background for the current state of the game.
    /// </summary>
    public static void DrawBackground()
    {
        // If the player is at the Main menu screen or the Game menu screen or the Settings screen or the High scores screen.
        if ((((GameController.CurrentState == GameState.ViewingMainMenu) || (GameController.CurrentState == GameState.ViewingGameMenu)) || (GameController.CurrentState == GameState.AlteringSettings)))
        {
            SwinGame.DrawBitmap(GameResources.GameImage("Menu"), 0, 0);
        }
        // If the player is at the Discovering screen or the End game screen.
        else if ((GameController.CurrentState == GameState.Discovering) || (GameController.CurrentState == GameState.EndingGame))
        {
            SwinGame.DrawBitmap(GameResources.GameImage("Discovery"), 0, 0);
        }
        // If the player is at the Deploying phase screen.
        else if (GameController.CurrentState == GameState.Deploying)
        {
            SwinGame.DrawBitmap(GameResources.GameImage("Deploy"), 0, 0);
        }
        else if (GameController.CurrentState == GameState.ViewingHighScores)
        {
            SwinGame.DrawBitmap(GameResources.GameImage("EndScore"), 0, 0);
        }
        // If its any other screen.
        else
        {
            SwinGame.ClearScreen();
        }

        SwinGame.DrawFramerate(675, 585, GameResources.GameFont("CourierSmall"));
    }
예제 #15
0
        public static void Main()
        {
            //Open the game window
            SwinGame.OpenGraphicsWindow("GameMain", 800, 800);
            // SwinGame.ShowSwinGameSplashScreen();
            Board board = new Board();

            BoardSetup.SetUpBoard(board);
            BoardSetup.SetupPices(board);


            //Run the game loop
            while (false == SwinGame.WindowCloseRequested())
            {
                //Fetch the next batch of UI interaction
                SwinGame.ProcessEvents();

                //Clear the screen and draw the framerate
                SwinGame.ClearScreen(Color.White);
                SwinGame.DrawFramerate(0, 0);
                //
                // drawing cells on the board
                BoardDrawing.DrawBoard(board);
                BoardDrawing.DrawPieces(board);
                if (SwinGame.MouseClicked(MouseButton.RightButton))
                {
                    board.GetSingleCell.SelectedShapesAt(SwinGame.MousePosition());
                }

                //BoardSetup.SetupPices (board);
                //Draw onto the screen
                SwinGame.RefreshScreen(60);
            }
        }
        /// <summary>
        /// Draws the background for the current state of the game
        /// </summary>

        public static void DrawBackground()
        {
            switch (GameController.CurrentState)
            {
            case GameState.ViewingMainMenu:
            case GameState.ViewingGameMenu:
            case GameState.AlteringSettings:
            case GameState.ViewingHighScores:
                SwinGame.DrawBitmap(GameResources.GameImage("Menu"), 0, 0);
                //SwinGame.DrawText(GameController.CurrentState.ToString(),Color.Red,300,100);
                break;

            case GameState.Discovering:
            case GameState.EndingGame:
                SwinGame.DrawBitmap(GameResources.GameImage("Discovery_" + _currentBackground.ToString()), 0, 0);
                //SwinGame.DrawText(GameController.CurrentState.ToString(),Color.Red,300,100);
                break;

            case GameState.Deploying:
                SwinGame.DrawBitmap(GameResources.GameImage("Deploy"), 0, 0);
                //SwinGame.DrawText(GameController.CurrentState.ToString(),Color.Red,300,100);
                break;

            default:
                SwinGame.ClearScreen();
                //SwinGame.DrawText(GameController.CurrentState.ToString(),Color.Red,300,100);
                break;
            }

            SwinGame.DrawFramerate(675, 585, GameResources.GameFont("CourierSmall"));
        }
예제 #17
0
    /// <summary>
    /// Draws the background for the current state of the game
    /// </summary>
    public static void DrawBackground()
    {
        if ((((GameController.CurrentState == GameState.ViewingMainMenu) || (GameController.CurrentState == GameState.ViewingGameMenu)) || (GameController.CurrentState == GameState.AlteringSettings)) || (GameController.CurrentState == GameState.AlterMusics) || (GameController.CurrentState == GameState.ViewingHighScores))
        {
            SwinGame.DrawBitmap(GameResources.GameImage("Menu"), 0, 0);
        }
        else if ((GameController.CurrentState == GameState.Discovering) || (GameController.CurrentState == GameState.EndingGame))
        {
            SwinGame.DrawBitmap(GameResources.GameImage("Discovery"), 0, 0);
        }
        else if (GameController.CurrentState == GameState.Deploying)
        {
            SwinGame.DrawBitmap(GameResources.GameImage("Deploy"), 0, 0);
        }
        else if (GameController.CurrentState == GameState.ViewingInstructions)
        {
            SwinGame.DrawBitmap(GameResources.GameImage("Instructions"), 0, 0);
        }
        else
        {
            SwinGame.ClearScreen();
        }

        SwinGame.DrawFramerate(585, 580, GameResources.GameFont("CourierSmall"));
    }
예제 #18
0
    /// <summary>
    /// Draws the background for the current state of the game
    /// </summary>

    public static void DrawBackground()
    {
        switch (CurrentState)
        {
        case GameState.ViewingMainMenu:
        case GameState.ViewingGameMenu:
        case GameState.AlteringSettings:
        case GameState.ViewingHighScores:
            SwinGame.DrawBitmap(GameImage("Menu"), 0, 0);
            break;

        case GameState.Discovering:
        case GameState.EndingGame:
            SwinGame.DrawBitmap(GameImage("Discovery"), 0, 0);
            break;

        case GameState.Deploying:
            SwinGame.DrawBitmap(GameImage("Deploy"), 0, 0);
            break;

        default:
            SwinGame.ClearScreen();
            break;
        }

        SwinGame.DrawFramerate(675, 585, GameFont("CourierSmall"));
    }
예제 #19
0
    /// <summary>
    /// Draws the background for the current state of the game
    /// </summary>

    public static void DrawBackground()
    {
        switch (GameController.CurrentState)
        {
        case GameState.ViewingMainMenu:
        case GameState.ViewingGameMenu:
        case GameState.AlteringSetting:
        case GameState.BGMSettings:
        case GameState.AlteringSetup:
        case GameState.ViewingHighScores:
            SwinGame.DrawBitmap(GameResources.GameImage("Menu"), 0, 0);
            break;

        case GameState.Discovering:
        case GameState.EndingGame:
            SwinGame.DrawBitmap(GameResources.GameImage("Discovery"), 0, 0);
            break;

        case GameState.Deploying:
            SwinGame.DrawBitmap(GameResources.GameImage("Deploy"), 0, 0);
            break;

        default:
            SwinGame.ClearScreen();
            break;

        case GameState.HowToPlay:

            SwinGame.DrawBitmap(GameResources.GameImage("Menu"), 0, 0);

            GameResources.GameFont("New").FontStyle = FontStyle.BoldFont | FontStyle.UnderlineFont;
            SwinGame.DrawText("How To Play : BATTLESHIP", MENU_COLOR, GameResources.GameFont("New"), HOWTOPLAYOFFSET_LEFT, 10 + HOWTOPLAYOFFSET_TOP);

            GameResources.GameFont("New").FontStyle = FontStyle.BoldFont;
            SwinGame.DrawText("*DIFFICULTY", MENU_COLOR, GameResources.GameFont("New"), HOWTOPLAYOFFSET_LEFT, 50 + HOWTOPLAYOFFSET_TOP);
            SwinGame.DrawText("Choose between Easy, Medium and Hard", MENU_COLOR, GameResources.GameFont("New"), HOWTOPLAYOFFSET_LEFT, 70 + HOWTOPLAYOFFSET_TOP);
            SwinGame.DrawText("*HIGH SCORES", MENU_COLOR, GameResources.GameFont("New"), HOWTOPLAYOFFSET_LEFT, 100 + HOWTOPLAYOFFSET_TOP);
            SwinGame.DrawText("Click on the scores button to view the Player's high score", MENU_COLOR, GameResources.GameFont("New"), HOWTOPLAYOFFSET_LEFT, 120 + HOWTOPLAYOFFSET_TOP);
            SwinGame.DrawText("*OBJECTIVE", MENU_COLOR, GameResources.GameFont("New"), HOWTOPLAYOFFSET_LEFT, 150 + HOWTOPLAYOFFSET_TOP);
            SwinGame.DrawText("Destroy the opponent's ships", MENU_COLOR, GameResources.GameFont("New"), HOWTOPLAYOFFSET_LEFT, 170 + HOWTOPLAYOFFSET_TOP);
            SwinGame.DrawText("*SCORING", MENU_COLOR, GameResources.GameFont("New"), HOWTOPLAYOFFSET_LEFT, 200 + HOWTOPLAYOFFSET_TOP);
            SwinGame.DrawText("Each time the player hits the opponent's ship, 1 point will be given", MENU_COLOR, GameResources.GameFont("New"), HOWTOPLAYOFFSET_LEFT, 220 + HOWTOPLAYOFFSET_TOP);
            SwinGame.DrawText("*Special Moves", MENU_COLOR, GameResources.GameFont("New"), HOWTOPLAYOFFSET_LEFT, 250 + HOWTOPLAYOFFSET_TOP);
            SwinGame.DrawText("Rotate or Shuffle the ship's position", MENU_COLOR, GameResources.GameFont("New"), HOWTOPLAYOFFSET_LEFT, 280 + HOWTOPLAYOFFSET_TOP);
            SwinGame.DrawText("*MUTE", MENU_COLOR, GameResources.GameFont("New"), HOWTOPLAYOFFSET_LEFT, 310 + HOWTOPLAYOFFSET_TOP);
            SwinGame.DrawText("Click on the mute button to turn off the sound and music", MENU_COLOR, GameResources.GameFont("New"), HOWTOPLAYOFFSET_LEFT, 340 + HOWTOPLAYOFFSET_TOP);

            if (SwinGame.KeyTyped(KeyCode.vk_ESCAPE))
            {
                GameController.EndCurrentState();
            }

            break;
        }

        SwinGame.DrawFramerate(675, 585, GameResources.GameFont("CourierSmall"));
    }
예제 #20
0
        public static void Main()
        {
            InitializeGame();

            //Open the game window
            SwinGame.OpenGraphicsWindow("GameMain", 900, 600);
            //SwinGame.ShowSwinGameSplashScreen ();

            //Run the game loop
            while (false == SwinGame.WindowCloseRequested())
            {
                //Fetch the next batch of UI interaction
                SwinGame.ProcessEvents();

                //Clear the screen and draw the framerate
                SwinGame.ClearScreen(Color.DarkGray);
                SwinGame.DrawFramerate(0, 0);
                gameBoard.Draw();
                DrawSideBar();
                if (turn == 1)
                {
                    gameBoard.AIMove();
                }

                if (SwinGame.MouseClicked(MouseButton.LeftButton))
                {
                    gameBoard.SelectCell(SwinGame.MousePosition());
                }

                if ((SwinGame.MouseX() >= 604 && SwinGame.MouseX() <= 705) && (SwinGame.MouseY() >= 150 && SwinGame.MouseY() <= 250))
                {
                    SwinGame.DrawText("Revive", Color.Black, SwinGame.MouseX(), SwinGame.MouseY() + 20);
                    if (SwinGame.MouseClicked(MouseButton.LeftButton))
                    {
                        gameBoard.CastMagic(MagicType.Revive);
                    }
                }
                else if ((SwinGame.MouseX() >= 794 && SwinGame.MouseX() <= 865) && (SwinGame.MouseY() >= 165 && SwinGame.MouseY() <= 235))
                {
                    SwinGame.DrawText("Invulnerability", Color.Black, SwinGame.MouseX() - 40, SwinGame.MouseY() + 20);
                    if (SwinGame.MouseClicked(MouseButton.LeftButton))
                    {
                        gameBoard.CastMagic(MagicType.Invulnerability);
                    }
                }


                if (SwinGame.MouseClicked(MouseButton.RightButton))
                {
                    SwinGame.DrawText(SwinGame.MouseX().ToString() + "," + SwinGame.MouseY().ToString(), Color.Black, SwinGame.MouseX() + 10, SwinGame.MouseY());
                    //SwinGame.Delay (50);
                }

                //Draw onto the screen
                SwinGame.RefreshScreen(60);
            }
        }
예제 #21
0
        /*=================*/
        /* Private Methods */
        /*=================*/

        private static void Loop()
        {
            Scene activeScene = _scenes.Peek();             // get active scene

            SwinGame.ProcessEvents();                       // process SwinGame events
            activeScene.Update();                           // update active scene
            SwinGame.ClearScreen(Color.Black);              // clear the screen
            activeScene.Render();                           // draw the active scene
            SwinGame.DrawFramerate(0, 0);                   // draw the framerate
            SwinGame.RefreshScreen(60);                     // refresh the screen
        }
        public static void Main()
        {
            Drawing myDrawing = new Drawing();

            //Open the game window
            SwinGame.OpenGraphicsWindow("GameMain", 800, 600);
            SwinGame.ShowSwinGameSplashScreen();

            //Run the game loop
            while (false == SwinGame.WindowCloseRequested())
            {
                //Fetch the next batch of UI interaction
                SwinGame.ProcessEvents();

                //Clear the screen and draw the framerate
                SwinGame.ClearScreen(Color.White);
                SwinGame.DrawFramerate(0, 0);


                myDrawing.Draw();

                //Draw onto the screen
                SwinGame.RefreshScreen(60);



                if (SwinGame.MouseClicked(MouseButton.LeftButton))
                {
                    SwinGame.FillCircle(Color.AliceBlue, 50, 50, 50);
                    Shape myShape = new Shape();
                    myShape.X = SwinGame.MouseX();
                    myShape.Y = SwinGame.MouseY();
                    myDrawing.AddShape(myShape);
                }

                if (SwinGame.KeyTyped(KeyCode.vk_SPACE))
                {
                    SwinGame.GUISetBackgroundColor(SwinGame.RandomRGBColor(255));
                }

                if (SwinGame.MouseClicked(MouseButton.RightButton))
                {
                    myDrawing.SelectShapesAt(SwinGame.MousePosition());
                }

                if (SwinGame.KeyDown(KeyCode.vk_DELETE))
                {
                    foreach (Shape s in myDrawing.SelectedShapes)
                    {
                        myDrawing.RemoveShape(s);
                    }
                }
            }
        }
예제 #23
0
    //Draws the background for the current state of the game
    public static void DrawBackground()
    {
        switch (GameController.CurrentState)
        {
        case GameState.ViewingMainMenu:
        case GameState.ViewingGameMenu:
        case GameState.AlteringSettings:
        case GameState.AlteringMenuColor:
        case GameState.ViewingHighScores:
            SwinGame.DrawBitmap(GameResources.GameImage("Menu"), 0, 0);
            break;

        case GameState.Discovering:
        case GameState.EndingGame:
            SwinGame.DrawBitmap(GameResources.GameImage("Discovery"), 0, 0);
            break;

        case GameState.Deploying:
            SwinGame.DrawBitmap(GameResources.GameImage("Deploy"), 0, 0);
            break;

        case GameState.Instructions:
            SwinGame.DrawBitmap(GameResources.GameImage("InstructionsPage"), 0, 0);
            SwinGame.DrawText("--Instructions for Battleship--", Color.Blue, GameResources.GameFont("Courier"), 250, 10);

            SwinGame.DrawText("--BASIC STUFF--", Color.Yellow, GameResources.GameFont("Courier"), 100, 40);
            SwinGame.DrawText("--DIFFICULTY--", Color.Yellow, GameResources.GameFont("Courier"), 100, 60);
            SwinGame.DrawText("Choose between 3 Difficulties; Easy, Medium and Hard", Color.White, GameResources.GameFont("Courier"), 100, 80);

            SwinGame.DrawText("--HIGH SCORES--", Color.Yellow, GameResources.GameFont("Courier"), 100, 100);
            SwinGame.DrawText("Click on the scores button to view the Player's high score", Color.White, GameResources.GameFont("Courier"), 100, 120);

            SwinGame.DrawText("--AIM OF THE GAME--", Color.Yellow, GameResources.GameFont("Courier"), 100, 140);
            SwinGame.DrawText("Destroy all the opponent's ships in order to win", Color.White, GameResources.GameFont("Courier"), 100, 160);

            SwinGame.DrawText("--SCORING--", Color.Yellow, GameResources.GameFont("Courier"), 100, 190);
            SwinGame.DrawText("Each time the player hits the opponent's ship, 1 point will be given", Color.White, GameResources.GameFont("Courier"), 100, 210);

            SwinGame.DrawText("--GAME INSTRUCTIONS--", Color.Yellow, GameResources.GameFont("Courier"), 100, 300);
            SwinGame.DrawText("1. During Ship deployment stage, you can either place the ship on the grid", Color.White, GameResources.GameFont("Courier"), 100, 320);
            SwinGame.DrawText("horizontally or vertically. Or you can select the random shuffle which deploys", Color.White, GameResources.GameFont("Courier"), 100, 340);
            SwinGame.DrawText("all the ship on the grid for you. Note: All ship must be deployed before", Color.White, GameResources.GameFont("Courier"), 100, 360);
            SwinGame.DrawText("starting the game.", Color.White, GameResources.GameFont("Courier"), 100, 380);
            SwinGame.DrawText("2.During the attack stage, you will just need to Click on the grid", Color.White, GameResources.GameFont("Courier"), 100, 430);
            SwinGame.DrawText("in order to attack enemy's ship.", Color.White, GameResources.GameFont("Courier"), 100, 450);
            break;

        default:
            SwinGame.ClearScreen();
            break;
        }
        SwinGame.DrawFramerate(675, 585);
    }
예제 #24
0
        /// <summary>
        /// Main Function, main acces point for the program
        /// </summary>
        public static void Main()
        {
            GameObjects.Polyhedra.Add(new A9(35));

            GameObjects.Polyhedra[0].Offset(new Vector(80, 80));
            //Open the game window
            SwinGame.OpenGraphicsWindow(Title + " v" + Version, 800, 600);

            //SwinGame.ToggleFullScreen();
            //SwinGame.ShowSwinGameSplashScreen();

            //Load the game assets
            GameResources.LoadResources();

            GameScores.Initalise();

            //Run the game loop
            while (false == SwinGame.WindowCloseRequested())
            {
                //Fetch the next batch of UI interaction
                SwinGame.ProcessEvents();

                InputController.ProcessMovement();

                //Clear the screen and draw the framerate
                SwinGame.ClearScreen(Color.Black);

                SwinGame.DrawFramerate(0, 0);

                if (SwinGame.KeyDown(KeyCode.vk_z))
                {
                    GameObjects.Polyhedra[0].Scale(1.01);
                }
                if (SwinGame.KeyDown(KeyCode.vk_x))
                {
                    GameObjects.Polyhedra[0].Scale(0.99);
                }


                //Update Game

                GameObjects.Draw(Color.Goldenrod, Color.DarkGoldenrod);

                tick++;

                //Draw onto the screen
                SwinGame.RefreshScreen(60);
            }

            GameResources.FreeResources();
        }
예제 #25
0
        public static void Main()
        {
            //Open the game window
            SwinGame.OpenGraphicsWindow("TowerWars", 800, 600);
            SwinGame.ShowSwinGameSplashScreen();
            //Load images and animations
            SwinGame.LoadResourceBundle("characterbundle.txt");
            //Initialise all game components
            GameManager       manager          = new GameManager();
            Currency          currency         = new Currency(manager);
            TeamManager       teamManager      = new TeamManager();
            ErrorManager      errManager       = new ErrorManager();
            HomeTower         home             = new HomeTower();
            EnemyTower        enemy            = new EnemyTower();
            HealthManager     healthManager    = new HealthManager(teamManager, home, enemy);
            CollisionManager  collisionManager = new CollisionManager(manager, teamManager, healthManager, home, enemy);
            DeploymentManager deployManager    = new DeploymentManager(manager, currency, teamManager, errManager);
            GamePainter       painter          = new GamePainter(manager, currency);

            //Run the game loop
            while (false == SwinGame.WindowCloseRequested())
            {
                //Fetch the next batch of UI interaction
                SwinGame.ProcessEvents();
                //Paint all elements on to the screen
                painter.Paint();

                //Handle game over
                if (manager.Running)
                {
                    deployManager.handleInput(SwinGame.MousePosition());
                    deployManager.spawnUnits();
                    collisionManager.handleCollisions();
                    errManager.handleErrors();
                    currency.update();
                }
                else
                {
                    teamManager.clearTeams();
                    manager.drawWinLoseMessage();
                }
                //Keep bases/health on screen, all the time.
                painter.paintHomeBase(Position.HOME_BASE_X, Position.HOME_BASE_Y);
                painter.paintEnemeyBase(Position.ENEMY_BASE_X, Position.ENEMY_BASE_Y);
                healthManager.updateHealth();
                SwinGame.DrawFramerate(0, 0);

                //Draw onto the screen
                SwinGame.RefreshScreen(60);
            }
        }
예제 #26
0
        /// <summary>
        /// run the game
        /// </summary>
        public void Run()
        {
            while (!ExitRequested())
            {
                SwinGame.ClearScreen(windowColor);
                SwinGame.ProcessEvents();

                Update();
                Draw();

                SwinGame.DrawFramerate(0, 0);
                SwinGame.RefreshScreen(60);
            }
        }
예제 #27
0
    /// <summary>
    /// Draws the background for the current state of the game
    /// </summary>

    public static void DrawBackground()
    {
        switch (GameController.CurrentState)
        {
        case GameState.ViewingMainMenu:
        case GameState.ViewingGameMenu:
        case GameState.AlteringSettings:
        case GameState.ViewingHighScores:
            SwinGame.DrawBitmap(GameResources.GameImage("Menu"), 0, 0);
            break;

        case GameState.Discovering:
        case GameState.EndingGame:
            SwinGame.DrawBitmap(GameResources.GameImage("Discovery"), 0, 0);
            break;

        case GameState.Deploying:
            SwinGame.DrawBitmap(GameResources.GameImage("Deploy"), 0, 0);
            break;

        case GameState.GameGuide:
            SwinGame.DrawBitmap(GameResources.GameImage("Menu"), 0, 0);
            SwinGame.DrawText("GAME GUIDE : BATTLESHIP", Color.Yellow, GameResources.GameFont("Courier"), 0, 10);
            SwinGame.DrawText(">>DIFFICULTY", Color.Yellow, GameResources.GameFont("Courier"), 0, 40);
            SwinGame.DrawText("You can choose between 3 difficulties EASY,MEDIUM,HARD", Color.Yellow, GameResources.GameFont("Courier"), 0, 50);
            SwinGame.DrawText(">>HIGH SCORES", Color.Yellow, GameResources.GameFont("Courier"), 0, 70);
            SwinGame.DrawText("To view high score click on the score button in main menu", Color.Yellow, GameResources.GameFont("Courier"), 0, 80);
            SwinGame.DrawText(">>OBJECTIVE", Color.Yellow, GameResources.GameFont("Courier"), 0, 100);
            SwinGame.DrawText("Destroy the opponent's ships", Color.Yellow, GameResources.GameFont("Courier"), 0, 110);
            SwinGame.DrawText(">>CALCULATION OF SCORE", Color.Yellow, GameResources.GameFont("Courier"), 0, 130);
            SwinGame.DrawText("Each time the player hits the opponent's ship, 1 point will be given", Color.Yellow, GameResources.GameFont("Courier"), 0, 140);
            SwinGame.DrawText(">>PREPARING FOR GAME", Color.Yellow, GameResources.GameFont("Courier"), 0, 160);
            SwinGame.DrawText("You can add ships in the grid on your own or you can click on randomize button", Color.Yellow, GameResources.GameFont("Courier"), 0, 170);
            SwinGame.DrawText(">>UPDATES", Color.Red, GameResources.GameFont("Courier"), 0, 190);
            SwinGame.DrawText("Added a list of enemy's ship in gameplay screen", Color.White, GameResources.GameFont("Courier"), 0, 200);
            SwinGame.DrawText("Added a mute button in gameplay screen", Color.White, GameResources.GameFont("Courier"), 0, 210);
            SwinGame.DrawText("Added a timer to gameplay screen", Color.White, GameResources.GameFont("Courier"), 0, 220);
            if (SwinGame.KeyTyped(KeyCode.vk_ESCAPE))
            {
                GameController.EndCurrentState();
            }
            break;

        default:
            SwinGame.ClearScreen();
            break;
        }

        SwinGame.DrawFramerate(675, 585, GameResources.GameFont("CourierSmall"));
    }
예제 #28
0
        public static void Main()
        {
            SwinGame.OpenWindow("AntSim", GameState.WindowWidth, GameState.WindowHeight);
            Setup.Run();

            while (!SwinGame.WindowCloseRequested())
            {
                SwinGame.ClearScreen(Color.White);
                GameLogic.Process();
                GameLogic.Renderer.RenderAll();
                SwinGame.DrawFramerate(10, 10);
                SwinGame.RefreshScreen(60);
            }
        }
예제 #29
0
        /// <summary>
        /// Used to draw all IDrawable objects to the screen.
        /// </summary>
        public static void Draw()
        {
            //Clear the screen and draw the framerate
            SwinGame.ClearScreen(Color.White);
            SwinGame.DrawFramerate(0, 0);

            foreach (IDrawable d in StateController.Instance.IDrawableList)
            {
                d.Draw();
            }

            //Draw onto the screen
            SwinGame.RefreshScreen(60);
        }
예제 #30
0
        public static void Main()
        {
            //Open the game window
            SwinGame.OpenGraphicsWindow("GameMain", 800, 600);
            //SwinGame.ShowSwinGameSplashScreen();
            Drawing myDrawing = new Drawing();

            //Run the game loop
            while (false == SwinGame.WindowCloseRequested())
            {
                //Fetch the next batch of UI interaction
                SwinGame.ProcessEvents();

                //Clear the screen and draw the framerate
                myDrawing.Draw();
                SwinGame.DrawFramerate(0, 0);

                //Button Functions
                //spawn new shape
                if (SwinGame.MouseClicked(MouseButton.LeftButton))
                {
                    Shape s = new Shape();
                    s.X = SwinGame.MouseX();
                    s.Y = SwinGame.MouseY();
                    myDrawing.AddShape(s);
                }
                //randomise background color
                if (SwinGame.KeyTyped(KeyCode.SpaceKey))
                {
                    myDrawing.Background = SwinGame.RandomRGBColor(255);
                }
                //select
                if (SwinGame.MouseClicked(MouseButton.RightButton))
                {
                    myDrawing.SelectShapesAt(SwinGame.MousePosition());
                }
                //delete selected
                if ((SwinGame.KeyTyped(KeyCode.DeleteKey)) || (SwinGame.KeyTyped(KeyCode.BackspaceKey)))
                {
                    foreach (Shape selectedShape in myDrawing.SelectedShapes())
                    {
                        myDrawing.RemoveShape(selectedShape);
                    }
                }

                //Draw onto the screen
                SwinGame.RefreshScreen(60);
            }
        }