Esempio n. 1
0
 public override void OnCollide(GameObject o)
 {
     if (o.GetType() == typeof(Brick))
     {
         XVel = -XVel;
         YVel = -YVel;
     }
 }
Esempio n. 2
0
        public override void OnCollide(GameObject o)
        {
            if (o.GetType() != typeof(Ball))
                return;

            //
            //          0
            //          ---------
            //              |
            //          <--->
            //          distance between ball and center of paddle
            //          to determine the direction of drift to add to velocity
            //

            /*
             *                  0
             *
             *          --------------------
             *          |        |         |
             *          -45      0         +45
             *
             *
             * */

            //playerX = p.X;
            //playerY = p.Y;
            //playerCenterX = p.X - (p.Width / 2);
            Ball ball = o as Ball;

            ball.YVel = -ball.YVel;
            double diff = (ball.X + ball.Width / 2) - X;
            if (diff < Width / 2)
            {
                //Debug.WriteLine("BOUNCE LEFT");
                ball.XVel -= 1;
            }
            else
            {
                //Debug.WriteLine("BOUNCE RIGHT");
                ball.XVel += 1;
            }
        }
Esempio n. 3
0
 public virtual bool Intersects(GameObject o)
 {
     return CollisionBounds.IntersectsWith(o.CollisionBounds);
 }
Esempio n. 4
0
 public virtual void OnCollide(GameObject o)
 {
     Debug.WriteLine(String.Format("Collision: {0} -> {1}", this.ToString(), o.ToString()));
 }
Esempio n. 5
0
 public override void OnCollide(GameObject o)
 {
 }