예제 #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)
        {
            // For Mobile devices, this logic will close the Game when the Back button is pressed
            if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed)
            {
                Exit();
            }

            cam.Update(player.position);
            tellus.Update(cam, player);
            player.Update(cam, tellus);
            mouse.Update(cam, tellus, player);
            // TODO: Add your update logic here
            base.Update(gameTime);
        }
예제 #2
0
        protected override void Update(GameTime gameTime)
        {
            kState = Keyboard.GetState();
            if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed || Keyboard.GetState().IsKeyDown(Keys.Escape))
            {
                Exit();
            }


            if (kState.IsKeyDown(Keys.Left))
            {
                cam.Move(new Vector2(-2, 0));
            }
            if (kState.IsKeyDown(Keys.Right))
            {
                cam.Move(new Vector2(2, 0));
            }
            if (kState.IsKeyDown(Keys.Up))
            {
                cam.Move(new Vector2(0, -2));
            }
            if (kState.IsKeyDown(Keys.Down))
            {
                cam.Move(new Vector2(0, 2));
            }

            if (kState.IsKeyDown(Keys.D))
            {
                block.Move(1, 0);
            }
            if (kState.IsKeyDown(Keys.A))
            {
                block.Move(-1, 0);
            }
            if (kState.IsKeyDown(Keys.W))
            {
                block.Move(0, -1);
            }
            if (kState.IsKeyDown(Keys.S))
            {
                block.Move(0, 1);
            }

            if (kState.IsKeyDown(Keys.Enter))
            {
                graphics.ToggleFullScreen();
                AdjustResolution();
                graphics.ApplyChanges();
            }

            if (kState.IsKeyDown(Keys.NumPad8))
            {
                cam.ZoomIn();
            }
            if (kState.IsKeyDown(Keys.NumPad2))
            {
                cam.ZoomOut();
            }

            cam.Update(gameTime, Mouse.GetState());
            base.Update(gameTime);
        }