コード例 #1
0
ファイル: Form1.cs プロジェクト: Damillian/CSharp-tutorial
        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");
 }