Пример #1
0
        private Microsoft.VisualBasic.PowerPacks.ShapeContainer newRectangleShape(int x, int y, int sh, int sw, string name, int borderWidth)
        {
            Microsoft.VisualBasic.PowerPacks.ShapeContainer shapeContainervs = new Microsoft.VisualBasic.PowerPacks.ShapeContainer();
            Microsoft.VisualBasic.PowerPacks.RectangleShape rectangleShapevs = new Microsoft.VisualBasic.PowerPacks.RectangleShape();

            shapeContainervs.Location = new System.Drawing.Point(0, 0);
            shapeContainervs.Margin   = new System.Windows.Forms.Padding(0);
            shapeContainervs.Name     = "shapeContainer1";
            shapeContainervs.Shapes.AddRange(new Microsoft.VisualBasic.PowerPacks.Shape[] { rectangleShapevs });
            shapeContainervs.Size        = new Size(645, 614);
            shapeContainervs.TabIndex    = 0;
            shapeContainervs.TabStop     = false;
            rectangleShapevs.Location    = new Point(x, y);
            rectangleShapevs.Name        = name;
            rectangleShapevs.Size        = new Size(sh, sw);
            rectangleShapevs.BorderWidth = borderWidth;
            return(shapeContainervs);
        }
Пример #2
0
        public ping(string p)
        {
            InitializeComponent();
            nickname_p           = p;
            this.shapeContainer1 = new Microsoft.VisualBasic.PowerPacks.ShapeContainer();



            timer1.Enabled = true;
            Cursor.Hide();

            this.FormBorderStyle = FormBorderStyle.None;
            this.TopMost         = true;
            this.Bounds          = Screen.PrimaryScreen.Bounds;

            racket.Top = playground.Bottom - (playground.Bottom / 10);

            game_over_lbl.Left    = (playground.Width / 2) - (game_over_lbl.Width / 2);
            game_over_lbl.Top     = (playground.Height / 2) - (game_over_lbl.Height / 2);
            game_over_lbl.Visible = false;

            //This is the code of the bricks

            //This algorithm is the model of create Rectangle Shapes to instance bricks and Rectangles for test collisions (go to line 229 )

            rectPlayer = new Rectangle(ball.Location.X, ball.Location.Y, ball.Width, ball.Height); // modelling rectangles for player to test collision


            for (int row = playground.Height / 30; row < playground.Height / 3; row += playground.Height / 20)                  //For each "row" of bricks
            {
                for (double platform = (playground.Width / 100); platform < playground.Width; platform += playground.Width / 9) //For each "platform/collumns" of bricks
                {
                    int widthRect   = Convert.ToInt32(playground.Width / 10);                                                   //width of each brick
                    int predictable = Convert.ToInt32(platform) + (playground.Width / 10);                                      // the next platform

                    if (predictable < playground.Width)                                                                         //test to no instance a brick out of your monitor :p
                    {
                        //Configure the possition of the bricks, and the collor.
                        vectRectShape[j]           = new Microsoft.VisualBasic.PowerPacks.RectangleShape(Convert.ToInt32(platform), 70 + row, widthRect, 30);
                        vectRectShape[j].FillStyle = Microsoft.VisualBasic.PowerPacks.FillStyle.Solid;
                        vectRectShape[j].FillColor = Color.Red;;
                    }

                    j++;
                }
            }



            //
            // shapeContainer1
            //
            this.shapeContainer1.Location = new System.Drawing.Point(0, 0);
            this.shapeContainer1.Margin   = new System.Windows.Forms.Padding(0);
            this.shapeContainer1.Name     = "shapeContainer2";

            for (int k = j; k > 0; k--)
            {
                this.shapeContainer1.Shapes.Add(vectRectShape[k - 1]);   //Instance of the bricks
            }

            this.shapeContainer1.Size     = new System.Drawing.Size(663, 329);
            this.shapeContainer1.TabIndex = 13;
            this.shapeContainer1.TabStop  = false;

            this.playground.Controls.Add(this.shapeContainer1);
        }