Пример #1
0
        //method PlaySound must be imported from the .dll file winmm
        public Form1()
        {
            InitializeComponent();

            for (int i = 0; i < kNumberOfRows; i++)
            {
                Rows[i] = new Row(i);
            }

            ThePaddle.Position.X = 5;
            ThePaddle.Position.Y = this.ClientRectangle.Bottom - ThePaddle.Height;
            // this.ClientRectangle refers to the current container (the instance of Form1)

            TheBall.Position.Y = this.ClientRectangle.Bottom - 200;

            this.SetBounds(this.Left, this.Top, Rows[0].GetBounds().Width, this.Height);

            TheScore = new Score(ClientRectangle.Right - 50, ClientRectangle.Bottom - 180);
            //positions the score - 0 at this moment

            // choose Level
            SpeedDialog dlg = new SpeedDialog();
               /* makes sure that, if the DialogResult property of the button "OK" is on,
            the SpeedDialog form appears and stays on the screen, and timer's Interval
            gets an appropriate value */
            if (dlg.ShowDialog() == DialogResult.OK)
            {
                timer1.Interval = dlg.Speed;
            }
        }
Пример #2
0
        //method PlaySound must be imported from the .dll file winmm
        public Form1()
        {
            InitializeComponent();

            //set paddles position
            DownPaddle.Position.X = 125; ;
            DownPaddle.Position.Y = this.ClientRectangle.Bottom - DownPaddle.Height - 30;
            UpPaddle.Position.X = 125; ;
            UpPaddle.Position.Y = 0;
            // this.ClientRectangle refers to the current container (the instance of Form1)

            //ball's starting position
            TheBall.Position.Y = this.ClientRectangle.Bottom - 210;
            TheBall.Position.X = 166;

            info.Position.X = 80;
            info.Position.Y = this.ClientRectangle.Bottom - DownPaddle.Height - 7;

            this.SetBounds(this.Left, this.Top, 350, this.Height);

            UpScore = new Score(ClientRectangle.Left+3, ClientRectangle.Bottom - 27);
            DownScore = new Score(ClientRectangle.Right - 27, ClientRectangle.Bottom - 27);
            //positions the score - 0 at this moment

            PlaySoundInThread("BrickHit.wav");

            // choose Level
            SpeedDialog dlg = new SpeedDialog();
            /* makes sure that, if the DialogResult property of the button "OK" is on,
             the SpeedDialog form appears and stays on the screen, and timer's Interval
             gets an appropriate value */
            if (dlg.ShowDialog() == DialogResult.OK)
            {
                timer1.Interval = dlg.Speed;
            }
        }