Example #1
0
File: Form1.cs Project: sukov/Pong
        private void Form1_Load(object sender, EventArgs e)
        {
            Player1 = new Palka(this,sizePlayer);
            Player2 = new Palka(this,sizeAI);
            Player2.AI = true;

            this.Width = SCREEN_WIDTH;//sets the Form's Width
            this.Height = SCREEN_HEIGHT;//sets the Form's Height
            this.StartPosition = FormStartPosition.CenterScreen;//opens the form in center of the screen

            Player1.Pbox.Location = new Point(Player1.Pbox.Width / 2, ClientSize.Height / 2 - Player1.Pbox.Height / 2);//sets it's location (centered)
            Player1.Pbox.BackColor = Color.Blue;
            this.Controls.Add(Player1.Pbox);

            Player2.Pbox.Location = new Point(ClientSize.Width - (Player2.Pbox.Width + Player2.Pbox.Width / 2), ClientSize.Height / 2 - Player1.Pbox.Height / 2);
            Player2.Pbox.BackColor = Color.Red;
            this.Controls.Add(Player2.Pbox);

            //picBoxBall.Size = sizeBall;
              //  picBoxBall.Location = new Point(ClientSize.Width / 2 - picBoxBall.Width / 2, ClientSize.Height / 2 - picBoxBall.Height / 2);
              //  picBoxBall.BackColor = Color.Green;
              //  this.Controls.Add(picBoxBall);

            topka = new Topka(sizeBall,ballSpeedX,ballSpeedY);
            topka.Ball.Location = new Point(ClientSize.Width / 2 - topka.Ball.Width / 2, ClientSize.Height / 2 - topka.Ball.Height / 2);
            topka.Ball.BackColor = Color.Green;
            this.Controls.Add(topka.Ball);

            igra = new Igra(this, Player1, Player2, topka);
        }
Example #2
0
        private void Form1_Load(object sender, EventArgs e)
        {
            Player1 = new Palka(this,sizePlayer,false,flag);
            Player2 = new Palka(this,sizeAI,BOT,flag); //AI true,false

            this.BackgroundImage = Properties.Resources.bg_body;
            this.Width = SCREEN_WIDTH;//sets the Form's Width
            this.Height = SCREEN_HEIGHT;//sets the Form's Height
            this.StartPosition = FormStartPosition.CenterScreen;//opens the form in center of the screen

            Player1.Pbox.Location = new Point(Player1.Pbox.Width / 2, ClientSize.Height / 2 - Player1.Pbox.Height / 2);//sets it's location (centered)
            Player1.Pbox.BackColor = Color.Blue;
            this.Controls.Add(Player1.Pbox);

            Player2.Pbox.Location = new Point(ClientSize.Width - (Player2.Pbox.Width + Player2.Pbox.Width / 2), ClientSize.Height / 2 - Player1.Pbox.Height / 2);
            Player2.Pbox.BackColor = Color.Red;
            this.Controls.Add(Player2.Pbox);

            topka = new Topka(sizeBall,ballSpeedX,ballSpeedY);
            topka.Ball.Location = new Point(ClientSize.Width / 2 - topka.Ball.Width / 2, ClientSize.Height / 2 - topka.Ball.Height / 2);

               //topka.Ball.Image = Properties.Resources.logo;
            this.Controls.Add(topka.Ball);

            igra = new Igra(this, Player1, Player2, topka,flag);
        }