Example #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();
            }

            if (InputManager.IsKeyDown(Keys.Right))
            {
                sprite.Radius++;
            }
            if (InputManager.IsKeyDown(Keys.Left))
            {
                sprite.Radius--;
            }
            if (InputManager.IsKeyDown(Keys.Up))
            {
                sprite.Speed += 0.05f;
            }
            if (InputManager.IsKeyDown(Keys.Down))
            {
                sprite.Speed -= 0.05f;
            }

            Time.Update(gameTime);
            InputManager.Update();
            sprite.Update();
            base.Update(gameTime);
        }
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)
        {
            if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed || Keyboard.GetState().IsKeyDown(Keys.Escape))
            {
                Exit();
            }

            // TODO: Add your update logic here
            // *** Pre-Lab2

            /*
             * KeyboardState currentState = Keyboard.GetState();
             * if (currentState.IsKeyDown(Keys.Left) && preState.IsKeyUp(Keys.Left)) sprite.Position += Vector2.UnitX * -5;
             * if (currentState.IsKeyDown(Keys.Right) && preState.IsKeyUp(Keys.Right)) sprite.Position += Vector2.UnitX * 5;
             * if (currentState.IsKeyDown(Keys.Space)) sprite.Rotation += 0.05f;
             * preState = currentState;*/
            // *** Lab2
            Time.Update(gameTime);
            InputManager.Update();
            spiralMover.Update();

            base.Update(gameTime);
        }