コード例 #1
0
ファイル: Ball.cs プロジェクト: thiecrow/Pong
        public override void Update(GameTime gameTime, GameObjects gameObjects)
        {
            if (attachedToPaddle != null)
            {
                Location.X = attachedToPaddle.Location.X + attachedToPaddle.GetWidth() - 1;
                Location.Y = attachedToPaddle.Location.Y + attachedToPaddle.GetHeigth() / 2 - texture.Height / 2;
            }
            else
            {
                if (BoundingBox.Intersects(gameObjects.PlayerPaddle.BoundingBox) || BoundingBox.Intersects(gameObjects.ComputerPaddle.BoundingBox))
                {
                    velocity.X = -velocity.X;
                }
            }

            Launch();
            base.Update(gameTime, gameObjects);

            checkBounds();
        }