示例#1
0
        public void Update(GameTime gameTime, Kinect kinectState, Ball ball)
        {
            //if (kinectState.Side == KinectSide.Left && Position.Y > 0)
            //{
            //    _direction = new Vector2(0, -1);
            //}
            //else if (kinectState.Side == KinectSide.Rigth && Position.Y + Texture.Height < 600)
            //{
            //    _direction = new Vector2(0, 1);
            //}
            //else
            //{
            //    _direction = Vector2.Zero;
            //}
            //Position += _direction * _velocity * (float)gameTime.ElapsedGameTime.TotalSeconds;
            //Position = new Vector2(Position.X, kinectState.Posicao);

            float distance;
            if (side == 0)
            {
                distance = Position.Y - kinectState.PosicaoLeft;
            }
            else
            {
                distance = Position.Y - kinectState.PosicaoRigth;
            }
            if (distance < 0)
            {
                _direction = new Vector2(0, 1);
            }
            else
            {
                _direction = new Vector2(0, -1);
            }
            distance *= Math.Sign(distance);

            Position += _direction * (distance * 30) * (float)gameTime.ElapsedGameTime.TotalSeconds;

            UpdateBallState(ball);
        }
示例#2
0
 /// <summary>
 /// Allows the game to perform any initialization it needs to before starting to run.
 /// This is where it can query for any required services and load any non-graphic
 /// related content.  Calling base.Initialize will enumerate through any components
 /// and initialize them as well.
 /// </summary>
 protected override void Initialize()
 {
     this.objectsOnScreen = new List<IObject>();
     this.objectsOnScreen
         .Add(new Objects.Ball(this)
         {
             Direction = new Vector2(1, 0), Velocity = 100.0f
         }
     );
     kinect = new Kinect();
     // TODO: Add your initialization logic here
     base.Initialize();
 }