/// <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) { // Allows the game to exit if (input.ButtonDown(Buttons.B)) { this.Exit(); } if (input.KeyDown(Keys.Escape)) { this.Exit(); } MouseState mouseState = Mouse.GetState(); float elapsedSeconds = (float)gameTime.ElapsedGameTime.Milliseconds / 1000.0f; float forwardReq = 0; Vector3 moveDirection = new Vector3(0, 0, 0); if (input.KeyDown(Keys.S)) { forwardReq += 5.0f; moveDirection = new Vector3(0, 0, 1); //Backward } if (input.KeyDown(Keys.W)) { forwardReq += 5.0f; moveDirection = new Vector3(0, 0, -1); //Forward } if (input.KeyDown(Keys.A)) { forwardReq += 5.0f; moveDirection = new Vector3(-1, 0, 0); //Left } if (input.KeyDown(Keys.D)) { forwardReq += 5.0f; moveDirection = new Vector3(1, 0, 0); //Right } camera.AddToCameraPosition(moveDirection, forwardReq, ref initalPos1, gameTime, false); person1.Position = initalPos1; for (int i = 0; i < models.Count; i++) { models[i].WorldMatrix = Matrix.CreateScale(2.0f); } camera.Update(mouseState, person1.Position); person1.WorldMatrix = Matrix.CreateScale(2.0f) * Matrix.CreateRotationY(4.05f); base.Update(gameTime); }
protected override void Update(GameTime time) { camera.Update(time); // Exit if escape is pressed if (Keyboard.IsKeyTyped(Key.Escape)) { Exit(); } base.Update(time); }
/// <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) { // Allows the game to exit if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed) { this.Exit(); } if (Keyboard.GetState().IsKeyDown(Keys.Escape)) { Exit(); } MouseState mouseState = Mouse.GetState(); KeyboardState keyState = Keyboard.GetState(); camera.Update(mouseState, keyState); base.Update(gameTime); }
public void Update(GameTime gameTime) { _camera.Update(gameTime); }