Example #1
0
        protected override void Update(GameTime gameTime)
        {
            if (Keyboard.GetState().IsKeyDown(Keys.Escape))
            {
                Exit();
            }

            if (gameOver)
            {
                if (Keyboard.GetState().IsKeyDown(Keys.Space))
                {
                    Reset();
                }
            }

            if (board.CheckOutOfBounds(player.getHead()) || player.SelfCollide())
            {
                GameOver();
            }
            else
            {
                player.Update(gameTime);
                if (food.getRect().Intersects(player.getHead()))
                {
                    score++;
                    player.IncreaseLength();
                    food.NewPos();
                }
            }

            base.Update(gameTime);
        }