예제 #1
0
        public KeyboardContext(Form form)
        {
            keyboard = new StratumKeyboardManager(form);
            keyboard.Initialize();

            previousState = keyboard.GetState();
            currentState = previousState;
        }
예제 #2
0
 public static void Update()
 {
     lastWheel = Wheel;
     lastX = X;
     lastY = Y;
     state = Game.Keyboard.GetState();
     mouseState = Game.Mouse.GetState();
 }
예제 #3
0
        // Update the camera based on user input
        public void Update(GameTime gameTime, KeyboardState keyboardState, MouseState mouseState)
        {
            var time = (float)gameTime.TotalGameTime.TotalSeconds;
            var elapsedTime = (float)gameTime.ElapsedGameTime.Milliseconds;

            if (freeCamera)
            {
                // Calculate the yaw and pitch
                float yaw = 0.5f - mouseState.X;
                float pitch = 0.5f - mouseState.Y;

                //// Yaw
                //float yaw = 0;
                //if (keyboardState.IsKeyDown(Keys.Left)) { yaw++; }
                //if (keyboardState.IsKeyDown(Keys.Right)) { yaw--; }
                yaw *= elapsedTime * mouseSensitivity;

                //// Pitch

               // if (keyboardState.IsKeyDown(Keys.Up)) { pitch++; }
               // if (keyboardState.IsKeyDown(Keys.Down)) { pitch--; }
               // pitch *= elapsedTime * mouseSensitivity;

                // Roll with Q and E
                float roll = 0;
                if (keyboardState.IsKeyDown(Keys.Q)) { roll--; }
                if (keyboardState.IsKeyDown(Keys.E)) { roll++; }
                roll *= elapsedTime * rollSpeed;

                // Forward and backward
                if (keyboardState.IsKeyDown(Keys.W)) { MoveCamera(-rotation.Forward, elapsedTime); }
                if (keyboardState.IsKeyDown(Keys.S)) { MoveCamera(-rotation.Backward, elapsedTime); }

                // Strafe
                if (keyboardState.IsKeyDown(Keys.A)) { MoveCamera(rotation.Left, elapsedTime); }
                if (keyboardState.IsKeyDown(Keys.D)) { MoveCamera(rotation.Right, elapsedTime); }

                // Rotate camera
                rotation *= Matrix.RotationAxis(rotation.Left, pitch);
                rotation *= Matrix.RotationAxis(rotation.Forward, roll);
                rotation *= Matrix.RotationAxis(rotation.Down, yaw);
            }
            UpdateViewMatrix();
        }
예제 #4
0
        protected override void Update(GameTime gameTime)
        {
            if (started)
            {
                // Update the keyboard and mouse state
                keyboardState = keyboardManager.GetState();
                mouseState = mouseManager.GetState();
                mouseManager.SetPosition(mouseCenter);
                accelerometerReading = input.accelerometer.GetCurrentReading();

                // Check collisions
                for (var i = 0; i < allBalls.Count; i++)
                {
                    if (!allBalls[i].Equals(player) && player.CollidedWith(allBalls[i]))
                        {
                            player.Collide(allBalls[i]);
                        }
                }

                // Quit
                if (keyboardState.IsKeyDown(Keys.Escape))
                {
                    this.Exit();
                    this.Dispose();
                    App.Current.Exit();
                }

                // Update camera based on the above
                camera.Update(gameTime, keyboardState, mouseState);

                // Finally update models
                landscape.Update(gameTime);
                sun.Update(gameTime);

                // Update balls
                for (var i = 0; i < allBalls.Count; i++)
                {
                    allBalls[i].Update(gameTime);
                }

                mainPage.UpdateScore(score);

                // Handle base.Update
                base.Update(gameTime);
            }
        }
예제 #5
0
        protected override void Update(GameTime gameTime)
        {
            keyboardState = keyboardManager.GetState();
            mouseState = mouseManager.GetState();
            model.Update(gameTime);
            sun.Update(gameTime);

            // Handle base.Update
            base.Update(gameTime);
        }
예제 #6
0
        protected override void Update(GameTime gameTime)
        {
            // read the current keyboard state
            keyboardState = keyboarManager.GetState();

            base.Update(gameTime);
        }
예제 #7
0
        protected override void Update(GameTime gameTime)
        {
            base.Update(gameTime);

            // Calculates the world and the view based on the model size
            view = Matrix.LookAtRH(new Vector3(0.0f, 0.0f, 7.0f), new Vector3(0, 0.0f, 0), Vector3.UnitY);
            projection = Matrix.PerspectiveFovRH(0.9f, (float)GraphicsDevice.BackBuffer.Width / GraphicsDevice.BackBuffer.Height, 0.1f, 100.0f);

            // Update basic effect for rendering the Primitive
            _textureEffect.View = view;
            _textureEffect.Projection = projection;
            _textureEffect.CameraPosition = new Vector3(0.0f, 0.0f, 70.0f);

            _exampleEffect.View = view;
            _exampleEffect.Projection = projection;
            _exampleEffect.CameraPosition = new Vector3(0.0f, 0.0f, 70.0f);

            // Get the current state of the keyboard
            keyboardState = keyboard.GetState();

            if (keyboardState.IsKeyPressed(Keys.D1))
                _wireframe ^= true;
        }
예제 #8
0
        protected override void Update(GameTime gameTime)
        {
            base.Update(gameTime);

            // handle input
            var keyboardState = _keyboardManager.GetState();

            if (keyboardState.IsKeyDown(Keys.Escape) && _previousKeyboardState.IsKeyUp(Keys.Escape)) Exit();

            if (keyboardState.IsKeyDown(Keys.T) && _previousKeyboardState.IsKeyUp(Keys.T))
            {
                _isBorderEnabled = !_isBorderEnabled;
                _residencyManager.SetBorderMode(_isBorderEnabled);
                _residencyManager.Reset();
            }

            var time = (float)gameTime.ElapsedGameTime.TotalSeconds;

            if (keyboardState.IsKeyDown(Keys.A)) _camera.Left(time);
            if (keyboardState.IsKeyDown(Keys.D)) _camera.Right(time);
            if (keyboardState.IsKeyDown(Keys.W)) _camera.Up(time);
            if (keyboardState.IsKeyDown(Keys.S)) _camera.Down(time);
            if (keyboardState.IsKeyDown(Keys.Q)) _camera.ZoomIn(time);
            if (keyboardState.IsKeyDown(Keys.E)) _camera.ZoomOut(time);

            _previousKeyboardState = keyboardState;
        }
예제 #9
0
        protected override void Update(GameTime gameTime)
        {
            keyboardState = keyboardManager.GetState();
            mouseState = mouseManager.GetState();

            // Handle base.Update
            base.Update(gameTime);

            //Update game objects
            lightsource.Update(gameTime);
            model.Update(gameTime, lightsource.getLightDirection());
            water.Update(gameTime, lightsource.getLightDirection());
            camera.Update(gameTime);

            //Enable/disable cursor control of the camera
            if (keyboardState.IsKeyPressed(Keys.Space)){
                if(enableCursor == true){
                    enableCursor = false;
                }
                else{
                    enableCursor = true;
                }
            }

            //Exit the game
            if (keyboardState.IsKeyDown(Keys.Escape))
            {
                this.Exit();
                this.Dispose();
            }
        }
예제 #10
0
        public override void Update(GameTime gameTime)
        {
            base.Update(gameTime);

            state = nextState;

            nextState.ResetPressedReleased();
        }
예제 #11
0
        /// <summary>
        /// Frame update method.
        /// </summary>
        /// <param name="gameTime">Time since last update.</param>
        protected override void Update(GameTime gameTime)
        {
            if (started) //Do nothing if the game has not started
            {
                if (gameOver == true)   //Exit if you lose. NO SECOND CHANCES
                {
                    this.Exit();
                    this.Dispose();
                    App.Current.Exit();
                    return;
                }

                keyboardState = keyboardManager.GetState(); //Get keyboard state
                flushAddedAndRemovedGameObjects();          //Add and remove waiting objects
                camera.Update();                            //Update the camera first
                accelerometerReading = input.accelerometer.GetCurrentReading(); //Read accelerometers
                for (int i = 0; i < gameObjects.Count; i++) //Update all other game objects and entities
                {
                    gameObjects[i].Update(gameTime);
                }

                mainPage.UpdateScore(score);    //Increment the player score
                mainPage.UpdateHitpoints(player.hitpoints); //Adjust the hitpoints display

                if (keyboardState.IsKeyDown(Keys.Escape)) //Exit the game when escape is mashed
                {
                    this.Exit();
                    this.Dispose();
                    App.Current.Exit();
                }

            }
            else
            {
                windowHeight = Window.ClientBounds.Height;
                windowWidth = Window.ClientBounds.Width;
            }

            // Handle base.Update
            base.Update(gameTime);
        }
예제 #12
0
 //this directly impacts the views based on the user's mouse and key input (AWSDQE and mouse)
 private Matrix UpdateViewMatrix()
 {
     keyboardState = keyboardManager.GetState();
     mouseState = mouseManager.GetState();
     float yawDx = 0.5f - mouseState.X;
     float pitchDy = 0.5f - mouseState.Y;
     yaw -= yawDx * mouseVelocity * gameTime.ElapsedGameTime.Milliseconds;
     pitch += pitchDy * mouseVelocity * gameTime.ElapsedGameTime.Milliseconds;
     if (keyboardState.IsKeyDown(Keys.Q))
     {
         roll += moveVelocity * gameTime.ElapsedGameTime.Milliseconds * .05f;
     }
     if (keyboardState.IsKeyDown(Keys.E))
     {
         roll -= moveVelocity * gameTime.ElapsedGameTime.Milliseconds * .05f;
     }
     Vector3 direction = new Vector3(
         (float)(Math.Cos(pitch) * Math.Sin(yaw)),
         (float)(Math.Sin(pitch)),
         (float)(Math.Cos(pitch) * Math.Cos(yaw)));
     Vector3 horizontalAxis = new Vector3(
         (float)(Math.Sin(yaw + Math.PI / 2f) * Math.Cos(roll)),
         (float)Math.Sin(roll), (float)(Math.Cos(yaw + Math.PI / 2f) * Math.Cos(roll)));
     Vector3 up = Vector3.Cross(direction, horizontalAxis);
     if (keyboardState.IsKeyDown(Keys.A))
     {
         Vector3 eyeChange = eye - moveVelocity * gameTime.ElapsedGameTime.Milliseconds * horizontalAxis;
         if (model.AllowMovement(eyeChange))
         {
         eye = eyeChange;
         }
     }
     if (keyboardState.IsKeyDown(Keys.D))
     {
         Vector3 eyeChange = eye + moveVelocity * gameTime.ElapsedGameTime.Milliseconds * horizontalAxis;
         if (model.AllowMovement(eyeChange))
         {
             eye = eyeChange;
         }
     }
     if (keyboardState.IsKeyDown(Keys.W))
     {
         Vector3 eyeChange = eye + moveVelocity * gameTime.ElapsedGameTime.Milliseconds * direction;
         if (model.AllowMovement(eyeChange))
         {
             eye = eyeChange;
         }
     }
     if (keyboardState.IsKeyDown(Keys.S))
     {
         Vector3 eyeChange = eye - moveVelocity * gameTime.ElapsedGameTime.Milliseconds * direction;
         if (model.AllowMovement(eyeChange))
         {
             eye = eyeChange;
         }
     }
     mouseManager.SetPosition(new Vector2(0.5f, 0.5f));
     return Matrix.LookAtLH(eye, eye + direction, up);
 }
예제 #13
0
파일: UI.cs 프로젝트: arcticnw/Wildmen
    /// <summary>
    /// Updates the user inputs
    /// </summary>
    /// <param id="gameTime">Time passed since the last call to Update</param>
    public void Update(GameTime gameTime)
    {
      pKeyb = cKeyb;
      pMouse = cMouse;
      cMouse = mMouse.GetState();
      cKeyb = mKeyb.GetState();

      prevMouseVector = MouseVector;
      MouseVector = GetMouseVector();

      if (prevMouseVector != MouseVector)
      {
        MouseStill = 0;
      }
      else
      {
        MouseStill += (int)gameTime.ElapsedGameTime.TotalMilliseconds;
      }

      UpdateNumber++;
    }
예제 #14
0
파일: UI.cs 프로젝트: arcticnw/Wildmen
    /// <summary>
    /// Initializes the user input-related variables
    /// </summary>
    /// <param id="gc"></param>
    public void Initialize(GameWindow gc)
    {
      this.gc = gc;

      mKeyb = new KeyboardManager(gc);
      mKeyb.Initialize();
      mMouse = new MouseManager(gc);
      mMouse.Initialize();

      pKeyb = mKeyb.GetState();
      pMouse = mMouse.GetState();

      nativeWindow = gc.Window.NativeWindow as System.Windows.Forms.Form;

      MouseVector = GetMouseVector();
      prevMouseVector = MouseVector;

      gc.Deactivated += win_Deactivated_handler;
      gc.Activated += win_Activated_handler;
      gc.Window.ClientSizeChanged += win_SizeChanged_handler;
    }
예제 #15
0
        protected override void Update(GameTime gameTime)
        {
            currentPositionInMazeArray = sphere.PositionInMaze(sphere.pos);
            if (started&&resumed)
            {
                currentGameTimeSecond += gameTime.ElapsedGameTime.TotalSeconds;
                keyboardState = keyboardManager.GetState();
                flushAddedAndRemovedGameObjects();
                accelerometerReading = input.accelerometer.GetCurrentReading();
                for (int i = 0; i < gameObjects.Count; i++)
                {
                   gameObjects[i].Update(gameTime);
                }

                mainPage.UpdateScore(score);

                if (keyboardState.IsKeyDown(Keys.Escape))
                {
                    this.Exit();
                    this.Dispose();
                    App.Current.Exit();
                }
                camera.Update();
                // Handle base.Update

            }

            if (currentPositionInMazeArray.X == mazeLandscape.maze.destX &&
                currentPositionInMazeArray.Y == mazeLandscape.maze.destY)
            {
                if (completeScreen == null)
                {
                    completeScreen = new CompleteScreen(mainPage, this, currentGameTimeSecond);
                }
                if( !mainPage.Children.Contains(completeScreen))
                {
                    mainPage.Children.Add(completeScreen);
                }
            }

            base.Update(gameTime);
        }
        ////////////////////////////////////////////////////////////////////////////    
        ////////////////////////////////////////////////////////////////////////////
        private void UpdateKeys(KeyboardState state, GameTime gameTime)
        {
            #if (!XBOX && !XBOX_FAKE)

              KeyEventArgs e = new KeyEventArgs();

              e.Caps = (((ushort)NativeMethods.GetKeyState(0x14)) & 0xffff) != 0;

              List<Keys> downKeys = new List<Keys>();
              state.GetDownKeys(downKeys);
              foreach (Keys key in downKeys)
              {
            if (key == Keys.LeftAlt || key == Keys.RightAlt) e.Alt = true;
            else if (key == Keys.LeftShift || key == Keys.RightShift) e.Shift = true;
            else if (key == Keys.LeftControl || key == Keys.RightControl) e.Control = true;
              }

              foreach (InputKey key in keys)
              {
            if (key.Key == Keys.LeftAlt || key.Key == Keys.RightAlt ||
            key.Key == Keys.LeftShift || key.Key == Keys.RightShift ||
            key.Key == Keys.LeftControl || key.Key == Keys.RightControl)
            {
              continue;
            }

            bool pressed = state.IsKeyDown(key.Key);

            double ms = gameTime.ElapsedGameTime.TotalMilliseconds;
            if (pressed) key.Countdown -= ms;

            if ((pressed) && (!key.Pressed))
            {
              key.Pressed = true;
              e.Key = key.Key;

              if (KeyDown != null) KeyDown.Invoke(this, e);
              if (KeyPress != null) KeyPress.Invoke(this, e);
            }
            else if ((!pressed) && (key.Pressed))
            {
              key.Pressed = false;
              key.Countdown = RepeatDelay;
              e.Key = key.Key;

              if (KeyUp != null) KeyUp.Invoke(this, e);
            }
            else if (key.Pressed && key.Countdown < 0)
            {
              key.Countdown = RepeatRate;
              e.Key = key.Key;

              if (KeyPress != null) KeyPress.Invoke(this, e);
            }
              }
              #endif
        }
예제 #17
0
        protected override void Update(GameTime gameTime)
        {
            keyboardState = keyboardManager.GetState();

            if (gameStarted)
            {

                // set the postition of the cannonball base on the landscape
                cannonModel.basicEffect.World = Matrix.RotationY(rotationY) * Matrix.Scaling(0.0003f) * Matrix.Translation(x0, y0 + 0.05f, z0);
                arrow.basicEffect.World = Matrix.Scaling(0.003f) * Matrix.Translation(x1, y1 + 0.3f + (float)arrow.ywave, z1);

                arrow.Update(gameTime);
                Debug.WriteLine(arrow.pos);

                accreading = input.accelerometer.GetCurrentReading();

                xadjust = (float) accreading.AccelerationX;

                if (!LaunchMode)
                {

                    launchViewUpdate();
                    //aim Cannon
                    rotationY = (float)((180 - degree) * Math.PI / 180);
                    if (keyboardState.IsKeyDown(Keys.Left))
                    {
                        rotationY -= speed;
                    }
                    if (keyboardState.IsKeyDown(Keys.Right))
                    {
                        rotationY += speed;
                    }
                    if (xadjust < 0.3 && xadjust > -0.3)
                    {
                        xadjust = 0;
                    }
                    rotationY += xadjust * 0.2f;

                    this.degree = 180 - rotationY / Math.PI * 180;
                    degree = this.mainpage.getDegreeValue();
                    this.mainpage.UpdateDegreeSlider((int)degree);

                }
                else
                {
                    //cannonball in air
                    CameraViewupdate();
                    Vector3 distanceMissed = new Vector3(landscape.getTargetPos().Position.X - ballMovement.pos.X,
                                                             landscape.getTargetPos().Position.Y - ballMovement.pos.Y,
                                                             landscape.getTargetPos().Position.Z - ballMovement.pos.Z);
                    if (justLaunched)
                    {

                //        BallViewUpdate();
                        attemptCount++;
                        mainpage.updateattempt(attemptCount);
                        justLaunched = false;
                    }
                    if (landscape.getHeight(ballMovement.pos.X, ballMovement.pos.Y) < ballMovement.pos.Y + 0.01f && !(distanceMissed.Length() < 0.1))
                    {
                        time += 0.004f;
                      //  this.ballParabolaMovement(time, this.x0, this.y0, this.z0, this.yDegree, this.degree);
                        if (landscape.getHeight(ballMovement.pos.X, ballMovement.pos.Y) < ballMovement.pos.Y)
                            ballMovement.Update(gameTime);
                        //  accelerometerReading = input.accelerometer.GetCurrentReading();
                        // this.degree += (float)accelerometerReading.AccelerationX;
                        //adjust path of ball
                        if (keyboardState.IsKeyDown(Keys.Left))
                        {
                            this.degree += 0.05f;

                        }
                        if (keyboardState.IsKeyDown(Keys.Right))
                        {
                            this.degree -= 0.05f;
                        }

                        this.degree += (float)-xadjust;

                    }
                    else
                    {
                        //next level
                        this.mainpage.viewLaunchControls();
                        LaunchMode = false;
                        time = 0;
                       //if win generate new level and update score
                        if(distanceMissed.Length() <0.1){
                            score +=(int)(10*difficulty);
                            difficulty += 1;
                            mainpage.UpdateScore(score);
                            if (attemptCount < bestAttempt || bestAttempt == 0)
                            {
                                bestAttempt = attemptCount;
                                attemptCount = 0;
                            }
                            mainpage.bestAttempt(bestAttempt);
                            mainpage.returnToMenu();
                            mainpage.hideLaunchControls();
                            this.LoadContent();
                        }

                    }
                }
                //accelerometerReading = input.accelerometer.GetCurrentReading();

                for (int i = 0; i < gameObjects.Count; i++)
                {
                    gameObjects[i].Update(gameTime);
                }

             /*   if (keyboardState.IsKeyDown(Keys.Tab) && isTabDown)
                {
                    isTabDown = false;
                    if (ballview)
                    {
                      /*  ballMovement.basicEffect.View = Matrix.LookAtLH(initMatrix, emptyMatrix, Vector3.UnitY);
                        landscape.basicEffect.View = Matrix.LookAtLH(initMatrix, emptyMatrix, Vector3.UnitY);
                        cannonModel.basicEffect.View = Matrix.LookAtLH(initMatrix, emptyMatrix, Vector3.UnitY);
                      arrow.basicEffect.View = Matrix.LookAtLH(initMatrix, emptyMatrix, Vector3.UnitY);*/
            /*                BallViewUpdate();
                        ballview = false;
                    }
                    else
                    {
                        ballview = true;
                    }
                }
                if (keyboardState.IsKeyUp(Keys.Tab))
                {
                    isTabDown = true;
                }

                if (ballview)
                {
                    CameraViewupdate();
                }
                else
                {
                    target1 = new Vector3(4, 0, -4);
                    target2 = landscape.getCannonPos().Position;
                    eye.X = target2.X - 0.1f * (target1.X - target2.X);
                    eye.Y = target2.Y - 0.1f * (target1.Y - target2.Y) + 0.1f;
                    eye.Z = target2.Z - 0.1f * (target1.Z - target2.Z);
                    // eye = new Vector3(target2.X - 1.0f, target2.Y + 0.3f, target2.Z - 1.0f);
                    up = Vector3.UnitY;
                    ballMovement.basicEffect.View = Matrix.LookAtLH(eye, target2, up);
                    landscape.basicEffect.View = Matrix.LookAtLH(eye, target2, up);
                    cannonModel.basicEffect.View = Matrix.LookAtLH(eye, target2, up);
                    arrow.basicEffect.View = Matrix.LookAtLH(eye, target2, up);
                    cannonModel.basicEffect.Projection = Matrix.PerspectiveFovLH((float)Math.PI / 4.0f, (float)cannonModel.game.GraphicsDevice.BackBuffer.Width / ballMovement.game.GraphicsDevice.BackBuffer.Height, 0.1f, 100.0f);
                }*/
                ballMovement.basicEffect.World = Matrix.Scaling(0.01f) * Matrix.Translation(ballMovement.pos);

                if (keyboardState.IsKeyDown(Keys.Escape))
                {
                    this.Exit();
                    this.Dispose();
                }
                // Handle base.Update
                //mainpage.UpdateScore(score);
                base.Update(gameTime);
            }
        }
예제 #18
0
 private static void UpdateKeyboard()
 {
     oldKeyboardState = keyboardState;
     keyboardState = keyboard.GetState();
 }
        protected override void Update(GameTime gameTime)
        {
            // Update the keyboard and mouse state
            keyboardState = keyboardManager.GetState();
            mouseState = mouseManager.GetState();
            mouseManager.SetPosition(mouseCenter);

            // Quit?
            if (keyboardState.IsKeyDown(Keys.Escape))
            {
                this.Exit();
            }

            // Update camera based on the above
            camera.Update(gameTime, keyboardState, mouseState);

            // Finally update models
            model.Update(gameTime, camera);
            sun.Update(gameTime, camera);

            // Handle base.Update
            base.Update(gameTime);
        }
        protected override void Update(GameTime gameTime)
        {
            // to get some input coming from the mouse and keyboard
            keyboardState = keyboardManager.GetState();
            mouseState = mouseManager.GetState();
            model.Update(gameTime);

            camera.Update(gameTime);

            if (keyboardState.IsKeyDown(Keys.Escape))
            {
                this.Exit();
                this.Dispose();
            }

            // Handle base.Update
            base.Update(gameTime);
        }
예제 #21
0
        protected override void Update(GameTime gameTime)
        {
            base.Update(gameTime);

            // update keyboard state
            previousKeyboardState = currentKeyboardState;
            currentKeyboardState = keyboardManager.GetState();

            // if Esc is pressed - quit program
            if (IsKeyPress(Keys.Escape))
            {
                Exit();
                return;
            }

            // numer keys (NOT numpad ones) have name like D0, D1, etc...
            // associate available modes each with its key
            for (int i = 0; i < availableModes.Count; i++)
            {
                var key = (Keys)Enum.Parse(typeof(Keys), "D" + i);
                if (IsKeyPress(key))
                {
                    ApplyMode(availableModes[i]);
                    return;
                }
            }
        }
예제 #22
0
        /// <summary>
        /// Update the state of all desired input devices.
        /// </summary>
        /// <param name="gameTime"></param>
        override public void Update(GameTime gameTime)
        {   
            // update state
            keyboardManager.Update(gameTime);
            keyboardState = keyboardManager.GetState();
            mouseState = mouseManager.GetState();
            pointerState = pointerManager.GetState();

              
            //mouseClick = mouseState.LeftButton.Pressed && !prevMouseState.LeftButton.Pressed;
            //mouseHeld = mouseState.LeftButton.Pressed && prevMouseState.LeftButton.Pressed;

            if (accelerometer != null) {
                accelerometerReading = accelerometer.GetCurrentReading();
                
            }

            // get mouse delta and reset mouse to centre of window
            if (useMouseDelta && mouseManager.Enabled) {
                mouseDelta = new Vector2(0.5f - mouseState.X, 0.5f - mouseState.Y);
                mouseManager.SetPosition(new Vector2(0.5f, 0.5f));
            }

            // record previous mouse state
            prevMouseState = mouseState;

 	        base.Update(gameTime);
        }
예제 #23
0
 protected override void Update(GameTime gameTime)
 {
     keyboardState = keyboardManager.GetState();
     if (started)
     {
         if (player.HasWon())
         {
             GraphicsDevice.Clear(Color.Black);
             mainPage.WinGame();
             return;
         }
         if (keyboardState.IsKeyDown(Keys.Q))
         {
             mainPage.QuitGame();
         }
         DoGhostStuff();
         flushAddedAndRemovedGameObjects();
         accelerometerReading = input.accelerometer.GetCurrentReading();
         player.Update(gameTime);
         for (int i = 0; i < gameObjects.Count; i++)
         {
             gameObjects[i].Update(gameTime);
         }
         mainPage.UpdateLives(player.ghostEncounters);
     }
     if (keyboardState.IsKeyDown(Keys.Escape))
     {
         this.Exit();
         this.Dispose();
         App.Current.Exit();
     }
     base.Update(gameTime);
 }
예제 #24
0
        protected override void Update(GameTime gameTime)
        {
            if (started)
            {
                keyboardState = keyboardManager.GetState();
                flushAddedAndRemovedGameObjects();

                accelerometerReading = input.accelerometer.GetCurrentReading();
                gyrometerReading = input.gyrometer.GetCurrentReading();

                camera.Update();
                for (int i = 0; i < gameObjects.Count; i++)
                {
                    gameObjects[i].Update(gameTime);
                }

                mainPage.UpdateScore(score);

                if (keyboardState.IsKeyDown(Keys.Escape))
                {
                    this.Exit();
                    this.Dispose();
                    App.Current.Exit();
                }
                // Handle base.Update
            }
            base.Update(gameTime);
        }
예제 #25
0
파일: HxDXApp.cs 프로젝트: kidveno/HaxeDx
        protected override void Update(GameTime gameTime)
        {
            base.Update(gameTime);

            // Calculates the world and the view based on the model size
            view = Matrix.LookAtLH(new Vector3(0.0f, 0.0f, -7.0f), new Vector3(0, 0.0f, 0), Vector3.UnitY);
            projection = Matrix.PerspectiveFovLH(0.9f, (float)GraphicsDevice.BackBuffer.Width / GraphicsDevice.BackBuffer.Height, 0.1f, 100.0f);

            // Update basic effect for rendering the Primitive
            basicEffect.View = view;
            basicEffect.Projection = projection;

            // Get the current state of the keyboard
            keyboardState = keyboard.GetState();

            // Get the current state of the mouse
            mouseState = mouse.GetState();
        }
예제 #26
0
 //public KeyboardContext(DirectInput directInput)
 //{
 //    //keyboard = new SharpDX.DirectInput.Keyboard(directInput);
 //    //keyboard.Acquire();
 //    //previousState = keyboard.GetCurrentState();
 //    //keyboard.Unacquire();
 //}
 public virtual void Update(GameTime gameTime)
 {
     previousState = currentState;
     currentState = keyboard.GetState();
 }
예제 #27
0
 public void UpdateInputDevices()
 {
     KeyboardState = KeyboardManager.GetState();
     KeyboardState.GetDownKeys(_downKeys);
     MouseState = MouseManager.GetState();
     if(PointerManager!=null)
         PointerState = PointerManager.GetState();
 }
 ////////////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////////////
 public virtual void SendKeyboardState(KeyboardState state, GameTime gameTime)
 {
     UpdateKeys(state, gameTime);
 }
예제 #29
0
        protected override void Update(GameTime gameTime)
        {
            mouse = Mouse.GetState();
            keyboard = Keyboard.GetState();

            switch(gameState)
            {
                case GameStates.MainMenu:
                    menu.Update(gameTime);
                    break;
                case GameStates.Play:
                    level.Update(gameTime);
                    break;
                case GameStates.Pause:
                    menu.Update(gameTime);
                    break;
                case GameStates.EndGame:
                    menu.Update(gameTime);
                    break;
                default:
                    break;
            }

            if (CurrentKeyboard.IsKeyDown(Keys.Alt) && CurrentKeyboard.IsKeyDown(Keys.F4)) Exit();

            currentSound.Volume = vol;

            base.Update(gameTime);
        }
예제 #30
0
        protected override void Update(GameTime gameTime)
        {
            if (started)
            {
                if (!player.alive)
                {
                    Platform.z_position = 0;
                    Platform.last_platform = new int[,] { { -1, 0 }, { -1, 0 }, { -1, 0 }, { -1, 0 }, { -1, 0 } };
                    Platform.next_platform = new int[,] { { 1, 0 }, { 1, 0 }, { 1, 0 }, { 1, 0 }, { 1, 0 } };

                    Platform.standing_platform = null;
                    Platform.next_standing_platform = null;
                    SetGameObjects();
                    started = false;
                    mainPage.EndGame(score);
                }
                else
                {
                    lightManager.Update();
                    keyboardState = keyboardManager.GetState();
                    flushAddedAndRemovedGameObjects();

                    // pass gameTime to let camera move along
                    camera.Update(gameTime, player.pos);

                    accelerometerReading = input.accelerometer.GetCurrentReading();

                    for (int i = 0; i < gameObjects.Count; i++)
                    {
                        gameObjects[i].Update(gameTime);
                    }

                    // Update score board on the game page
                    mainPage.UpdateScore(score);

                    // Update camera and player position for testing
                    mainPage.DisplayCameraPlayerPos(camera.Position, camera.cameraPos, player.pos, player.max_speed);
                    mainPage.UpdateShootButton(player.fireOn);

                    if (keyboardState.IsKeyDown(Keys.Escape))
                    {
                        this.Exit();
                        this.Dispose();
                        App.Current.Exit();
                    }
                    // Handle base.Update
                }
            }
            base.Update(gameTime);
        }