public override void OnCollide(GameObject o) { if (o.GetType() == typeof(Brick)) { XVel = -XVel; YVel = -YVel; } }
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; } }
public virtual bool Intersects(GameObject o) { return CollisionBounds.IntersectsWith(o.CollisionBounds); }
public virtual void OnCollide(GameObject o) { Debug.WriteLine(String.Format("Collision: {0} -> {1}", this.ToString(), o.ToString())); }
public override void OnCollide(GameObject o) { }