Ejemplo n.º 1
0
        /// <summary>
        /// This is called when the game should draw itself.
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of timing values.</param>
        protected override void Draw(GameTime gameTime)
        {
            GraphicsDevice.Clear(Color.Black);

            if (_currGameState == GAME_STATE_ENUM.Menu)
            {
                _currentState.Draw(gameTime, spriteBatch);
            }
            // TODO: Add your drawing code here

            if (_currentState.GetStateType() == true)
            {
                _currGameState = GAME_STATE_ENUM.Playing;
            }
            if (_currGameState == GAME_STATE_ENUM.Playing)
            {
                Console.WriteLine("Playing");
                spriteBatch.Begin();
                //Draw the game
                mPlayerSprite.Draw(this.spriteBatch);
                spriteBatch.End();
            }



            base.Draw(gameTime);
        }
Ejemplo n.º 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)
        {
            if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed || Keyboard.GetState().IsKeyDown(Keys.Escape))
            {
                Exit();
            }



            // TODO: Add your update logic here

            // START AT MENU
            if (_currentState.GetStateType() == false)
            {
                _currGameState = GAME_STATE_ENUM.Menu;
            }

            if (_nextState != null)
            {
                _currentState = _nextState;

                _nextState = null;
            }

            // GAME OVER
            if (mPlayerSprite.getCurrState() == mPlayerSprite.getDead())
            {
                // probably add a game over state or menu
                Exit();
            }

            if (_currentState.GetStateType() == true)
            {
                _currGameState = GAME_STATE_ENUM.Playing;
            }
            // _currentState.PostUpdate(gameTime);
            // PLAY
#pragma warning: initialized initial gamestate for testing


            if (_currGameState == GAME_STATE_ENUM.Playing)
            {
                if (mPlayerSprite == null)
                {
                    LoadContent();
                }
                mPlayerSprite.Update(gameTime);
            }

            // PAUSE
            // ADD A MENU HERE


            _currentState.Update(gameTime);
            base.Update(gameTime);
        }