Example #1
0
        /// <summary>
        /// LoadContent will be called once per game and is the place to load
        /// all of your content.
        /// </summary>
        protected override void LoadContent()
        {
            // Create a new SpriteBatch, which can be used to draw textures.
            spriteBatch = new SpriteBatch(GraphicsDevice);

            // TODO: use this.Content to load your game content here
            //board
            gameBoard = new Board(Content, new Vector2(0,0));
            //menubuttons
            playButton = new Button(Content, "play_button", GameState.Play, 20, 20);
            quitButton = new Button(Content, "quit_button", GameState.Quit, 20, 90);
        }
Example #2
0
        /// <summary>
        /// Allows the game to run logic such as updating the world,
        /// checking for collisions, gathering input, and playing audio.
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of timing values.</param>
        protected override void Update(GameTime gameTime)
        {
            // Allows the game to exit
            if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed)
                this.Exit();

            // TODO: Add your update logic here
            mouse = Mouse.GetState();
            keyboard = Keyboard.GetState();

            switch (gameState)
            {
                case GameState.Menu:
                    //menubuttons
                    playButton.Update(gameTime, mouse);
                    quitButton.Update(gameTime, mouse);
                break;

                case GameState.Play:
                    //board
                    if (gameBoard.HideLandMines(gameTime))
                    {
                        gameBoard.Update(gameTime, mouse, keyboard);
                        if (gameBoard.LifeBarCount == 0)
                        {
                            gameBoard = new Board(Content, new Vector2(0,0));
                            ChangeGameState(GameState.Menu);
                        }
                        if (gameBoard.FlowerCount == 0)
                        {
                            ChangeGameState(GameState.Win);
                        }
                    }
                break;

                case GameState.Win:
                    //create a new board and back to play
                    gameBoard = new Board(Content, new Vector2(0, 0));
                    ChangeGameState(GameState.Play);
                break;

                case GameState.Loose:
                break;

                case GameState.Quit:
                    this.Exit();
                break;
            }

            base.Update(gameTime);
        }