protected virtual void OnScored(Paddle.Side side, Ball ball) { EventHandler<ScoreEventArgs> handler = Scored; if (handler != null) { handler(this, new ScoreEventArgs(side, ball)); } }
public ScoreEventArgs(Paddle.Side side, Ball ball) { Side = side; Ball = ball; }
public void AddBall() { var ball = new Ball(25, new Random(DateTime.Now.Millisecond).Next(360), 2); Balls.Add(ball); ball.Scored += ball_Scored; }
private void DetermineMovement(Ball ballToTrack) { //Move paddle towards ball if (ballToTrack != null) { if (ballToTrack.Position.Y > Position.Y + Height/2) { SetDirection(_speed); } if (ballToTrack.Position.Y < Position.Y + Height/2) { SetDirection(-_speed); } } //Don't move when not! tracking a ball else { _yVelocity = 0; } }