示例#1
0
文件: Form1.cs 项目: 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);
        }
示例#2
0
文件: Igra.cs 项目: sukov/Pong
        public Igra(Form1 f,Palka Player1,Palka Player2,Topka Topka1)
        {
            this.f = f;
            this.Topka1 = Topka1;
            this.Player1 = Player1;
            this.Player2 = Player2;
            GameTime = new Timer();//Initializes the Timer

            GameTime.Enabled = true;//Enables the Timer
            GameTime.Interval = 1;//Set the timer's interval in miliseconds

            GameTime.Tick += new EventHandler(gameTime_Tick);//Creates the Timer's Tick event
        }
示例#3
0
文件: Igra.cs 项目: sokolmkd/PongGame
        public Igra(Form1 f,Palka Player1,Palka Player2,Topka Topka1,bool nin=false)
        {
            l = new Label();
            l.Text = "Zivoti:" + zivoti;
            l.BackColor = Color.Transparent;
            f.Controls.Add(l);
            ninja = nin;
            lista_ninja = new List<PictureBox>();
            this.f = f;
            this.Topka1 = Topka1;
            this.Player1 = Player1;
            this.Player2 = Player2;
            Score1 = new Label();
            Score2 = new Label();
            Score1.Text = "0";
            Score2.Text = "0";
            Score1.Location=new Point(100, 500);
            Score2.Location = new Point(700, 500);
            Score1.Font = new Font(Score1.Font.FontFamily, Score1.Font.Size + 5, Score1.Font.Style);
            Score2.Font = new Font(Score2.Font.FontFamily, Score2.Font.Size + 5, Score2.Font.Style);
            this.f.Controls.Add(Score1);
            if (!Player2.AI)
            {
                this.f.Controls.Add(Score2);
                f.KeyDown += new KeyEventHandler(f.Form1_KeyDown);
            }
            GameTime = new Timer();//Initializes the Timer

            GameTime.Enabled = true;//Enables the Timer
            GameTime.Interval =10;//Set the timer's interval in miliseconds

            GameTime.Tick += new EventHandler(gameTime_Tick);//Creates the Timer's Tick event

            if (!File.Exists("highscore.dat"))
                File.Create("highscore.dat");
            if (ninja)
            {
                dodaj_ninja();
            }
        }
示例#4
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);
        }