示例#1
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
            if (!gameOver)
            {
                if (collisonHandler.IsAnyColisson())
                {
                    gameOver = true;
                }

                dinosaur.HandleKeyboard(Keyboard.GetState());

                cactus.SpeedX  = GameConfig.WorldStatics.GameSpeed;
                cactus2.SpeedX = GameConfig.WorldStatics.GameSpeed;
                bird.SpeedX    = GameConfig.WorldStatics.GameSpeed;
                cactus.Update();
                cactus2.Update();
                dinosaur.Update();
                bird.Update();
                Console.WriteLine(cactus2.Pos.X);

                if (((int)gameTime.TotalGameTime.TotalSeconds) % 10 == 0)
                {
                    GameConfig.WorldStatics.SetGameSpeed(GameConfig.WorldStatics.GameSpeed + 0.05f);
                }
            }

            base.Update(gameTime);
        }