示例#1
0
        private void MoveObjects(object sender, EventArgs e)
        {
            player1.MoveBat();
            player2.MoveBat();
            ball.MoveBall();
            ball.CheckForCollision(player1, player2);

            string winner = ball.CheckForWinner();

            if (winner != null)
            {
                Console.WriteLine("the winner is " + winner);

                ball = new Ball(pbBall);

                if (winner == "p1")
                {
                    lblP1Score.Text = (Int32.Parse(lblP1Score.Text) + 1).ToString();
                }
                else
                {
                    lblP2Score.Text = (Int32.Parse(lblP2Score.Text) + 1).ToString();
                }
            }
        }
示例#2
0
文件: BallVM.cs 项目: empyty/PingPong
 private void TimerTick(object sender, EventArgs e)
 {
     ball.MoveBall();
     NotifyPropertyChanged("BallPositionX");
     NotifyPropertyChanged("BallPositionY");
 }