Esempio n. 1
0
        public void mePlay()
        {
            score.Text = "" + ScorePlayer;

            Ball.Top  -= BallY;
            Ball.Left -= BallX;


            if (Ball.Left < 0)
            {
                Ball.Left = 400;
                BallX     = -BallX;
                BallX    -= 2;
            }

            if (Ball.Left + Ball.Width > ClientSize.Width)
            {
                Ball.Left = 400;
                BallX     = -BallX;
                BallX    += 2;
                fail++;
            }

            if (Ball.Top < 0 || Ball.Top + Ball.Height > ClientSize.Height)
            {
                BallY = -BallY;
            }

            if (Ball.Bounds.IntersectsWith(Player.Bounds))
            {
                BallX = -BallX;
                ScorePlayer++;
            }

            if (Up == true && Player.Top > 0)
            {
                Player.Top -= 10;
            }

            if (Down == true && Player.Top < 400)
            {
                Player.Top += 10;
            }

            if (fail == 3)
            {
                timer1.Stop();
                MessageBox.Show("\tGAME OVER\t");

                fInfoPlayer f0 = new fInfoPlayer();
                this.Hide();
                f0.Show();
            }
        }
Esempio n. 2
0
        public void mePlay()
        {
            // Show score player on label1.
            diemc.Text = "" + ScorePlayer;

            // Show score computer on label2.
            diemm.Text = "" + ScoreComputer;

            Ball.Top  -= BallY;
            Ball.Left -= BallX;

            May.Top += Speed;

            if (ScoreComputer < 5)
            {
                if (May.Top < 0 || May.Top > 420)
                {
                    Speed = -Speed;
                }
            }
            else
            {
                May.Top = Ball.Top + 10;
            }



            if (Ball.Left < 0)
            {
                Ball.Left = 400;
                BallX     = -BallX;
                BallX    -= 2;
                ScoreComputer++;
            }

            if (Ball.Left + Ball.Width > ClientSize.Width)
            {
                Ball.Left = 400;
                BallX     = -BallX;
                BallX    += 2;
                ScorePlayer++;
            }
            if (Ball.Top < 0 || Ball.Top + Ball.Height > ClientSize.Height)
            {
                BallY = -BallY;
            }

            if (Ball.Bounds.IntersectsWith(NguoiChoi.Bounds) || Ball.Bounds.IntersectsWith(May.Bounds))
            {
                BallX = -BallX;
            }

            if (Up == true && NguoiChoi.Top > 0)
            {
                NguoiChoi.Top -= 10;
            }

            if (Down == true && NguoiChoi.Top < 420)
            {
                NguoiChoi.Top += 10;
            }



            if (ScorePlayer > 10)
            {
                timer1.Stop();
                MessageBox.Show("You win");

                fInfoPlayer f0 = new fInfoPlayer();
                this.Hide();
                f0.Show();
            }

            if (ScoreComputer > 10)
            {
                timer1.Stop();
                MessageBox.Show("The computer win ");
            }
        }