Esempio n. 1
0
        private void PlayerTwoMove(FrameEventArgs e)
        {
            KeyboardState kb = Keyboard.GetState();

            Artillery artilleryTwo = (Artillery)gameObjects[1];

            Vector2 oldPosition = artilleryTwo.Transform.Position;

            if (kb.IsKeyDown(Key.Left) ^ kb.IsKeyDown(Key.Right))
            {
                if (kb.IsKeyDown(Key.Left))
                {
                    artilleryTwo.Move(Direction.Left, e.Time);
                }
                else
                {
                    artilleryTwo.Move(Direction.Right, e.Time);
                }

                if (CheckCollision(artilleryTwo))
                {
                    artilleryTwo.Transform.Position = oldPosition;
                }
            }
        }