Пример #1
0
 /** <summary> Returns true if the control was released. </summary> */
 public override bool Released()
 {
     return((Ctrl == (Keyboard.IsKeyDown(Keys.LCtrl) || Keyboard.IsKeyDown(Keys.RCtrl))) &&
            (Shift == (Keyboard.IsKeyDown(Keys.LShift) || Keyboard.IsKeyDown(Keys.RShift))) &&
            (Alt == (Keyboard.IsKeyDown(Keys.LAlt) || Keyboard.IsKeyDown(Keys.RAlt))) &&
            Keyboard.IsKeyReleased(KeyCode));
 }
Пример #2
0
 /** <summary> Returns true if the control is up. </summary> */
 public override bool Up()
 {
     return((Ctrl != (Keyboard.IsKeyDown(Keys.LCtrl) || Keyboard.IsKeyDown(Keys.RCtrl))) ||
            (Shift != (Keyboard.IsKeyDown(Keys.LShift) || Keyboard.IsKeyDown(Keys.RShift))) ||
            (Alt != (Keyboard.IsKeyDown(Keys.LAlt) || Keyboard.IsKeyDown(Keys.RAlt))) ||
            Keyboard.IsKeyUp(KeyCode));
 }
Пример #3
0
        //-----------------------------------------------------------------------------
        // Updating
        //-----------------------------------------------------------------------------

        // Allows the game to run logic such as updating the world,
        // checking for collisions, gathering input, and playing audio.
        protected override void Update(GameTime gameTime)
        {
            if (!isContentLoaded)
            {
                Exit();
                return;
            }

            // Update the fullscreen mode.
            UpdateFullScreen();

            if (windowSizeChanged)
            {
                game.ScreenResized();
                windowSizeChanged = false;
            }

            // Update the frame rate.
            UpdateFrameRate(gameTime);

            // Update the listeners.
            if (Form.Focused)
            {
                Keyboard.Enable();
                GamePad.Enable();
                Mouse.Enable();
                Keyboard.Update(gameTime);
                GamePad.Update(gameTime);
                Mouse.Update(gameTime, (IsFullScreen ? -new Vector2F(Window.ClientBounds.Location) : Vector2F.Zero));
            }
            else
            {
                Keyboard.Disable(false);
                GamePad.Disable(false);
                Mouse.Disable(false);
            }
            AudioSystem.Update(gameTime);

            // Update the game logic.
            //game.Update((float) gameTime.ElapsedGameTime.TotalSeconds);

            // DEBUG: Hold 1 to speed up the game.
            if (Keyboard.IsKeyDown(Keys.D1))
            {
                for (int i = 0; i < 16; i++)
                {
                    game.Update((float)gameTime.ElapsedGameTime.TotalSeconds);
                }
            }
            // DEBUG: Hold 2 to slow down the game.
            else if (Keyboard.IsKeyDown(Keys.D2))
            {
                slowTimer++;
                if (slowTimer >= 10)
                {
                    slowTimer = 0;
                    game.Update((float)gameTime.ElapsedGameTime.TotalSeconds);
                }
            }
            else
            {
                // Update the game logic.
                game.Update((float)gameTime.ElapsedGameTime.TotalSeconds);
            }

            base.Update(gameTime);

            // Update screenshot requests.
            UpdateScreenShot();

            //windowSizeChanged = false;
        }
Пример #4
0
 public override bool Down()
 {
     return(Keyboard.IsKeyDown(KeyCode));
 }