public void MoveCloseToBall() { if (Math.Abs(ball.GetYposition() - cpuBar.YCenterOfBar()) > ProximityTolerance) { MoveCloserTo(ball.GetYposition()); } }
private int OffCollision(Bar bar) { // That's some interesting bit, how should the ball bounce when colliding with the bar?? // Let's make it simple: the further away from the middle of the bar, the least horizontally the ball will go var diff = yPosition - bar.YCenterOfBar(); var off = (diff) / 2; return(off); }
private int OffCollision(Bar bar) { // That's some interesting bit, how should the ball bounce when colliding with the bar?? // Let's make it simple: the further away from the middle of the bar, the least horizontally the ball will go var diff = yPosition - bar.YCenterOfBar(); var off = (diff) / 2; return off; }