Ejemplo n.º 1
0
        //Llenamos la matriz con los bloques
        private void LoadTiles()
        {
            int xAxis = 6;
            int yAxis = 4;
            // Aqui reducimos el tamaño de los bloques para que pueda encajar en el espacio asignado del juego
            int    pbHeight = (int)(Height * 0.3) / yAxis;
            int    pbWidth  = (int)(Width / 2.15) / xAxis;
            string number   = "7";
            int    block;

            _cpb = new CustomPictureBox[yAxis, xAxis];
            for (int i = 0; i < yAxis; i++)
            {
                // Aqui se manda a llamar la función RandomNumber para poder realizar la distribución de bloques
                // por cada fila.
                block   = RandomNumber(ref number);
                number += block;
                for (int j = 0; j < xAxis; j++)
                {
                    _cpb[i, j] = new CustomPictureBox();
                    // Si el bloque es igual al bloque numero 0, tendra un total de 3 golpes para ser destruido,
                    // y tendra el nombre clave: ThreeHit.
                    if (block == 0)
                    {
                        _cpb[i, j].hits = 3;
                        _cpb[i, j].Tag  = "ThreeHit";
                    }
                    // Si el bloque es igual al bloque numero 6, tendra un total de 2 golpes para ser destruido,
                    // y tendra el nombre clave: TwoHit.
                    else if (block == 6)
                    {
                        _cpb[i, j].hits = 2;
                        _cpb[i, j].Tag  = "TwoHit";
                    }
                    // Si el bloque es igual a un número dentro del rango 1-5,
                    // solo tendra un golpe para ser destruido, y tendra el nombre clave: OneHit.
                    else
                    {
                        _cpb[i, j].hits = 1;
                        _cpb[i, j].Tag  = "OneHit";
                    }

                    _cpb[i, j].Height = pbHeight;
                    _cpb[i, j].Width  = pbWidth;

                    //Aqui lo que hicimos fue que le cambiamos las coordenadas de aparicion de los bloques, para que
                    //encajara con el espacio asignado del juego
                    _cpb[i, j].Left                  = (int)(Width * 0.30) + j * pbWidth;
                    _cpb[i, j].Top                   = (int)(Height * 0.22) + i * pbHeight;
                    _cpb[i, j].BackgroundImage       = Image.FromFile("../../Resources/_" + (block) + ".png");
                    _cpb[i, j].BackgroundImageLayout = ImageLayout.Stretch;
                    _cpb[i, j].BackColor             = Color.Transparent;
                    Controls.Add(_cpb[i, j]);
                }
            }
        }
Ejemplo n.º 2
0
        // Metodo para cargar los bloques
        private void LoadTiles()
        {
            // Variables auxiliares para el calculo de tamano de cada cpb
            int xAxis = 20, yAxis = 5;

            remainingPb = xAxis * yAxis;

            int pbHeight = (int)(Height * 0.3) / yAxis;
            int pbWidth  = (Width - (xAxis - 20)) / xAxis;

            cpb = new CustomPictureBox[yAxis, xAxis];

            // Rutina de instanciacion y agregacion al UserControl
            for (int i = 0; i < yAxis; i++)
            {
                for (int j = 0; j < xAxis; j++)
                {
                    cpb[i, j] = new CustomPictureBox();

                    if (i == 3)
                    {
                        cpb[i, j].Hits = 2;
                    }
                    else
                    {
                        cpb[i, j].Hits = 1;
                    }

                    // Seteando el tamano
                    cpb[i, j].Height = pbHeight;
                    cpb[i, j].Width  = pbWidth;

                    // Posicion de left, y posicion de top
                    cpb[i, j].Left = j * pbWidth;
                    cpb[i, j].Top  = i * pbHeight + scorePanel.Height + 1;

                    // Si el valor de i = 3, entonces colocar ruta de imagen de bloque blindada
                    if (i == 3)
                    {
                        cpb[i, j].BackgroundImage = Image.FromFile("../../Img/armored.png");
                        cpb[i, j].Tag             = "blinded";
                    }
                    else
                    {
                        cpb[i, j].BackgroundImage = Image.FromFile("../../Img/" + GRN() + ".png");
                        cpb[i, j].Tag             = "tileTag";
                    }

                    cpb[i, j].BackgroundImageLayout = ImageLayout.Stretch;

                    Controls.Add(cpb[i, j]);
                }
            }
        }
        private void LoadTiles()
        {
            try
            {
                int xAxis = 10;
                int yAxis = 5;

                int PlatFormHeight = (int)(Height * 0.3) / yAxis;
                int PlatFormWidth  = (Width - (xAxis - 5)) / xAxis;

                cpb = new CustomPictureBox[yAxis, xAxis];

                for (int i = 0; i < yAxis; i++)
                {
                    for (int j = 0; j < xAxis; j++)
                    {
                        cpb[i, j] = new CustomPictureBox();

                        if (i == 0)
                        {
                            cpb[i, j].Golpes = 2;
                        }
                        else
                        {
                            cpb[i, j].Golpes = 1;
                        }


                        //Position from Height, Position from Width
                        cpb[i, j].Height = PlatFormHeight;
                        cpb[i, j].Width  = PlatFormWidth;


                        //Position from Left, Position from Top

                        cpb[i, j].Left = j * PlatFormWidth;
                        cpb[i, j].Top  = i * PlatFormHeight;

                        //If the value from i = 0, then put on the route from the brick pictureBox
                        cpb[i, j].BackgroundImage       = Image.FromFile("../../Textures/" + GRN() + ".png");
                        cpb[i, j].BackgroundImageLayout = ImageLayout.Stretch;

                        cpb[i, j].Tag = "tileTag";

                        Controls.Add(cpb[i, j]);
                    }
                }
            }
            catch (Exception exceptionGameOver)
            {
                MessageBox.Show("The game has end");
            }
        }
Ejemplo n.º 4
0
        // Metodo para Cargar los bloques.
        private void LoadBlocks()
        {
            // Variables auxiliares para el calculo de tamano de cada cpb
            int xAxis = 10, yAxis = 5;

            remainingBlocks = xAxis * yAxis;

            int pbWidth  = (Width - (xAxis - 5)) / xAxis;
            int pbHeight = (int)(Height * 0.3) / yAxis;

            cpb = new CustomPictureBox[yAxis, xAxis];

            for (int i = 0; i < yAxis; i++)
            {
                for (int j = 0; j < xAxis; j++)
                {
                    cpb[i, j] = new CustomPictureBox();

                    if (i == 0)
                    {
                        cpb[i, j].Hits            = 3;
                        cpb[i, j].BackgroundImage = Image.FromFile("../../Resources/Brick_Lvl3.jpg");
                        cpb[i, j].Tag             = "blockLevel3";
                    }
                    else if (i == 1 || i == 2)
                    {
                        cpb[i, j].Hits            = 2;
                        cpb[i, j].BackgroundImage = Image.FromFile("../../Resources/Brick_Lvl2.jpg");
                        cpb[i, j].Tag             = "blockLevel2";
                    }
                    else
                    {
                        cpb[i, j].Hits            = 1;
                        cpb[i, j].BackgroundImage = Image.FromFile("../../Resources/Brick_Lvl1.jpg");
                        cpb[i, j].Tag             = "blockLevel1";
                    }
                    // Tamano del cpb
                    cpb[i, j].Height = pbHeight;
                    cpb[i, j].Width  = pbWidth;

                    // Posicion de left, y posicion de top
                    cpb[i, j].Left = j * pbWidth;
                    cpb[i, j].Top  = i * pbHeight;
                    cpb[i, j].Top  = i * pbHeight + Scores.Height + 1;

                    cpb[i, j].BackgroundImageLayout = ImageLayout.Stretch;

                    Controls.Add(cpb[i, j]);
                }
            }
        }
        private void LoadTiles()
        {
            int pbWidth  = (Width - xAxis) / xAxis;
            int pbHeight = (int)(Height * 0.3) / yAxis;

            cpb = new CustomPictureBox[yAxis, xAxis];

            for (int i = 0; i < yAxis; i++)
            {
                for (int j = 0; j < xAxis; j++)
                {
                    cpb[i, j] = new CustomPictureBox();

                    if (i == yAxis - 1)
                    {
                        cpb[i, j].Hits = 2;
                    }

                    else
                    {
                        cpb[i, j].Hits = 1;
                    }

                    //Tamano de cpb
                    cpb[i, j].Height = pbHeight;
                    cpb[i, j].Width  = pbWidth;

                    //Posicion de left y top
                    cpb[i, j].Left = j * pbWidth;
                    cpb[i, j].Top  = i * pbHeight + scorePanel.Height + 1;

                    if (i == yAxis - 1)
                    {
                        //Seteando imagen de cpb en i==3
                        cpb[i, j].BackgroundImage = Image.FromFile("../../Resources/tb.png");
                        cpb[i, j].Tag             = "blinded";
                    }

                    else
                    {
                        //Seteando imagen de cpb
                        cpb[i, j].BackgroundImage = Image.FromFile("../../Resources/" + GRN() + ".png");
                        cpb[i, j].Tag             = "tileTag";
                    }

                    cpb[i, j].BackgroundImageLayout = ImageLayout.Stretch;
                    Controls.Add(cpb[i, j]);
                }
            }
        }
Ejemplo n.º 6
0
        private void LoadTiles()
        {
            int xAxis = 10, yAxis = 6;

            remainingPb = xAxis * yAxis;

            // Calculos para la ubicación de los elementos
            int pbHeight = (int)(Height * 0.4) / yAxis;
            int pbWidth  = (int)(Width - (Width * 0.45) - (xAxis - 5)) / xAxis;

            valorExtraWidth  = (int)(Width * 0.45) / 2;
            valorExtraHeight = (int)(Height * 0.20) / 2;

            cpb = new CustomPictureBox[yAxis, xAxis];

            // Llenado de bloques con logica de matrices

            for (int i = 0; i < yAxis; i++)
            {
                for (int j = 0; j < xAxis; j++)
                {
                    cpb[i, j] = new CustomPictureBox();

                    if (i == 0)
                    {
                        cpb[i, j].Hits            = 2;
                        cpb[i, j].BackgroundImage = Image.FromFile("../../Resources/0.png");
                    }
                    else
                    {
                        cpb[i, j].Hits            = 1;
                        cpb[i, j].BackgroundImage = Image.FromFile("../../Resources/" + GenerateRandomNumber() + ".png");
                    }

                    cpb[i, j].Height = pbHeight;
                    cpb[i, j].Width  = pbWidth;

                    //Posicion de left y posicion de top
                    cpb[i, j].Left = valorExtraWidth + (j * pbWidth);
                    cpb[i, j].Top  = valorExtraHeight + (i * pbHeight) + pnlScore.Height;

                    cpb[i, j].BackgroundImageLayout = ImageLayout.Stretch;
                    cpb[i, j].Tag = "tileTag";

                    Controls.Add(cpb[i, j]);
                }
            }
        }
        //Cargar bloques
        private void LoadTiles()
        {
            //establecer ejes y dimensiones para bloques
            int xAxis = 10, yAxis = 5;
            int pbHeight = (int)(Height * 0.3) / yAxis;
            int pbWidth  = (Width - (xAxis - 5)) / xAxis;

            cpb = new CustomPictureBox[yAxis, xAxis];
            for (int i = 0; i < yAxis; i++)
            {
                for (int j = 0; j < xAxis; j++)
                {
                    //crear bloque
                    cpb[i, j] = new CustomPictureBox();
                    //Definir nivel del bloque
                    if (i == 1)
                    {
                        cpb[i, j].Hits = 2;
                    }
                    else
                    {
                        cpb[i, j].Hits = 1;
                    }
                    //definir alto y ancho de bloque
                    cpb[i, j].Height = pbHeight;
                    cpb[i, j].Width  = pbWidth;
                    //posiciones
                    cpb[i, j].Left = j * pbWidth;
                    cpb[i, j].Top  = i * pbHeight + (int)(Height * 0.1);
                    //Definir sprite para bloque
                    if (i == 1)
                    {
                        cpb[i, j].BackgroundImage = Image.FromFile("../../img/blinded.png");
                    }
                    else
                    {
                        cpb[i, j].BackgroundImage = Image.FromFile("../../img/" + GRN() + ".png");
                    }
                    //configurar imagen y tag
                    cpb[i, j].BackgroundImageLayout = ImageLayout.Stretch;
                    cpb[i, j].Tag = "tileTag";
                    //Agregar bloque
                    Controls.Add(cpb[i, j]);
                }
            }
        }
Ejemplo n.º 8
0
        //Cargar bloques
        private void LoadTiles()
        {
            int xAxis = 10, yAxis = 7;

            //Altura y anchura de los bloques
            int cpbheight = (int)(Height * 0.5) / yAxis;
            int cpbwidth  = Width / xAxis;

            cpb = new CustomPictureBox[yAxis, xAxis];

            for (int i = 0; i < yAxis; i++)
            {
                for (int j = 0; j < xAxis; j++)
                {
                    //Cantidad de golpes necesarios
                    cpb[i, j] = new CustomPictureBox();
                    if (i == 0)
                    {
                        cpb[i, j].Hits = 3;
                    }
                    else if (i == 1)
                    {
                        cpb[i, j].Hits = 2;
                    }
                    else
                    {
                        cpb[i, j].Hits = 1;
                    }

                    //Altura y anchura
                    cpb[i, j].Height = cpbheight;
                    cpb[i, j].Width  = cpbwidth;

                    //Posiciones
                    cpb[i, j].Top  = i * cpbheight;
                    cpb[i, j].Left = j * cpbwidth;

                    //Cargar imagen
                    cpb[i, j].BackgroundImage       = Image.FromFile($"../../Recursos/{i+1}.png");
                    cpb[i, j].BackgroundImageLayout = ImageLayout.Stretch;

                    cpb[i, j].Tag = "tileTag";
                    Controls.Add(cpb[i, j]);
                }
            }
        }
Ejemplo n.º 9
0
        private void LoadTiles()
        {
            int xAxis    = 10;
            int yAxis    = 5;
            int LevelTop = 50;

            remainingtiles = xAxis * yAxis;

            int pHeight = (int)(Height * 0.29) / yAxis;
            int pWidth  = (Width - (xAxis - 5)) / xAxis;

            tiles = new CustomPictureBox[yAxis, xAxis];

            for (int i = 0; i < yAxis; i++)
            {
                for (int j = 0; j < xAxis; j++)
                {
                    tiles[i, j] = new CustomPictureBox();
                    if (i == 0)
                    {
                        tiles[i, j].Hits = 2;
                    }
                    else
                    {
                        tiles[i, j].Hits = 1;
                    }


                    tiles[i, j].Left = j * pWidth;
                    //top se cambia para dejar espacio para las vidas
                    tiles[i, j].Top = i * pHeight + scores.Height;

                    tiles[i, j].Height                = pHeight;
                    tiles[i, j].Width                 = pWidth;
                    tiles[i, j].BackgroundImage       = Image.FromFile("../../../../" + "Sprites/" + i + ".png");
                    tiles[i, j].BackgroundImageLayout = ImageLayout.Stretch;

                    tiles[i, j].Tag = "tileTag";
                    Controls.Add((tiles[i, j]));
                }
            }
        }
Ejemplo n.º 10
0
        // Metodo que agrega los bloques
        private void LoadTiles()
        {
            int xAxis = 10;
            int yAxis = 5;

            int pbHeight = (int)(Height * 0.2) / yAxis;
            int pbWidth  = (Width - xAxis) / xAxis;

            CustomPictureBox = new CustomPictureBox[yAxis, xAxis];

            for (int i = 0; i < yAxis; i++)
            {
                for (int j = 0; j < xAxis; j++)
                {
                    CustomPictureBox[i, j] = new CustomPictureBox();

                    if (i == 0)
                    {
                        CustomPictureBox[i, j].Hits = 2;
                    }
                    else
                    {
                        CustomPictureBox[i, j].Hits = 1;
                    }

                    CustomPictureBox[i, j].Height = pbHeight;
                    CustomPictureBox[i, j].Width  = pbWidth;

                    CustomPictureBox[i, j].Left = j * pbWidth;
                    CustomPictureBox[i, j].Top  = (i * pbHeight) + Scores.Height;


                    CustomPictureBox[i, j].BackgroundImage       = Image.FromFile("../../Img/" + GenerateRandomNumber() + ".png");
                    CustomPictureBox[i, j].BackgroundImageLayout = ImageLayout.Stretch;

                    CustomPictureBox[i, j].Tag = "tileTag";

                    Controls.Add(CustomPictureBox[i, j]);
                }
            }
        }
        private void LoadTile()
        {
            int xAxis = 10;
            int yAxis = 5;

            int pbHeight = (int)(Height * 0.3) / yAxis;
            int pbWidth  = Width / xAxis;

            cpb = new CustomPictureBox[yAxis, xAxis];
            for (int i = 0; i < yAxis; i++)
            {
                for (int j = 0; j < xAxis; j++)
                {
                    cpb[i, j] = new CustomPictureBox();
                    if (i == 0)
                    {
                        cpb[i, j].Golpes = 2;
                    }
                    else
                    {
                        cpb[i, j].Golpes = 1;
                    }

                    cpb[i, j].Height = pbHeight;
                    cpb[i, j].Width  = pbWidth;

                    cpb[i, j].Left = j * pbWidth;
                    cpb[i, j].Top  = i * pbHeight;

                    cpb[i, j].BackgroundImage       = Image.FromFile("../../../Res/" + (i + 1) + ".png");
                    cpb[i, j].BackgroundImageLayout = ImageLayout.Stretch;

                    cpb[i, j].Tag = "titleTag ";
                    Controls.Add(cpb[i, j]);
                }
            }
        }
        private void LoadTiles()
        {
            // Variables auxiliares para el calculo de tamano de cada cpb
            int xAxis = 10, yAxis = 5;

            remainingPb = xAxis * yAxis;

            int pbWidth  = (Width - (xAxis - 5)) / xAxis;
            int pbHeight = (int)(Height * 0.3) / yAxis;

            cpb = new CustomPictureBox[yAxis, xAxis];

            // Rutina de instanciacion y agregacion al UserControl
            for (int i = 0; i < yAxis; i++)
            {
                for (int j = 0; j < xAxis; j++)
                {
                    cpb[i, j] = new CustomPictureBox();

                    if (i == 4)
                    {
                        cpb[i, j].Hits = 2;
                    }
                    else
                    {
                        cpb[i, j].Hits = 1;
                    }

                    // Seteando el tamano
                    cpb[i, j].Height = pbHeight;
                    cpb[i, j].Width  = pbWidth;

                    // Posicion de left, y posicion de top
                    cpb[i, j].Left = j * pbWidth;
                    cpb[i, j].Top  = i * pbHeight + scorePanel.Height + 1;

                    int imageBack;
                    if (i % 2 == 0 && j % 2 == 0)
                    {
                        imageBack = 3;
                    }
                    else if (i % 2 == 0 && j % 2 != 0)
                    {
                        imageBack = 4;
                    }
                    else if (i % 2 != 0 && j % 2 == 0)
                    {
                        imageBack = 4;
                    }
                    else
                    {
                        imageBack = 3;
                    }

                    if (i == 4)
                    {
                        cpb[i, j].BackgroundImage = Image.FromFile("../../Img/tb1.png");
                        cpb[i, j].Tag             = "blinded";
                    }
                    else
                    {
                        cpb[i, j].BackgroundImage = Image.FromFile("../../Img/" + imageBack + ".png");
                        cpb[i, j].Tag             = "tileTag";
                    }

                    cpb[i, j].BackgroundImageLayout = ImageLayout.Stretch;

                    Controls.Add(cpb[i, j]);
                }
            }
        }
Ejemplo n.º 13
0
        private void LoadTiles()
        {
            int xAxis = 10, yAxis = 5;                    //10 tiles de "X" - y 5 tiles de "Y" |

            int pbWidth  = (Width - (xAxis - 5)) / xAxis; //ancho de la imagen
            int pbHeight = (int)(Height * 0.3) / yAxis;   //altura de la imagen

            cpb = new CustomPictureBox[yAxis, xAxis];     //matriz d picturesbox en donde estan ubicaos

            for (int i = 0; i < yAxis; i++)
            {
                for (int j = 0; j < xAxis; j++)
                {
                    //Level desing CREANDO LOS TILES
                    //BASE

                    cpb[i, j] = new CustomPictureBox();

                    if (i == 0)                //Son los tiles q estan al final de double hit
                    {
                        cpb[i, j].Golpes = 2;
                    }
                    else
                    {
                        cpb[i, j].Golpes = 1;
                    }

                    cpb[i, j].Height = pbHeight;
                    cpb[i, j].Width  = pbWidth;

                    // Posicion de left, y posicion de top
                    cpb[i, j].Left = j * pbWidth;
                    cpb[i, j].Top  = i * pbHeight + scores.Height + 1;

                    string tile = "Tile_";
                    if (i == 0)
                    {
                        tile = tile + "Hard";
                    }
                    else if (i % 2 == 0 && j % 2 == 0)
                    {
                        tile = tile + "Yellow";
                    }
                    else if (i % 2 == 0 && j % 2 != 0)
                    {
                        tile = tile + "Purple";
                    }
                    else if (i % 2 != 0 && j % 2 == 0)
                    {
                        tile = tile + "Purple";
                    }
                    else
                    {
                        tile = tile + "Yellow";
                    }

                    cpb[i, j].BackgroundImage       = Image.FromFile("../../Img/" + tile + ".png");
                    cpb[i, j].BackgroundImageLayout = ImageLayout.Stretch;

                    cpb[i, j].Tag = "tileTag";

                    Controls.Add(cpb[i, j]);
                }
            }

            DatosJuego.tiles = cpb.Length;
        }
        private void LoadTile()
        {
            //Creando el diseno de los cuadros atraves del custompicture box.
            int xAxis = 10;
            int yAxis = 5;

            int pbHeight = (int)(Height * 0.3) / yAxis;
            int pbWidth  = Width / xAxis;

            cpb = new CustomPictureBox[yAxis, xAxis];
            for (int i = 0; i < yAxis; i++)
            {
                for (int j = 0; j < xAxis; j++)
                {
                    //Crear el bloque
                    cpb[i, j] = new CustomPictureBox();
                    //Definir nivel del bloque
                    if (i == 1)
                    {
                        cpb[i, j].Golpes = 2;
                    }
                    else
                    {
                        cpb[i, j].Golpes = 1;
                    }
                    cpb[i, j].Height = pbHeight;
                    cpb[i, j].Width  = pbWidth;

                    //posiciones de la matriz
                    cpb[i, j].Left = j * pbWidth;
                    cpb[i, j].Top  = i * pbHeight;

                    if (i == 1)
                    {
                        cpb[i, j].BackgroundImage = Image.FromFile("../../Resources/blinded.png");
                    }
                    else
                    {
                        cpb[i, j].BackgroundImage = Image.FromFile("../../Resources/" + GRN() + ".png");
                    }
                    cpb[i, j].BackgroundImageLayout = ImageLayout.Stretch;

                    int imageBack;
                    if (i % 2 == 0 && j % 2 == 0)
                    {
                        imageBack = 3;
                    }
                    else if (i % 2 == 0 && j % 2 != 0)
                    {
                        imageBack = 4;
                    }
                    else if (i % 2 != 0 && j % 2 == 0)
                    {
                        imageBack = 4;
                    }
                    else
                    {
                        imageBack = 3;
                    }

                    if (i == 4)
                    {
                        cpb[i, j].BackgroundImage = Image.FromFile("../../Resources/tb1.png");
                        cpb[i, j].Tag             = "blinded";
                    }
                    else
                    {
                        cpb[i, j].BackgroundImage = Image.FromFile("../../Resources/" + imageBack + ".png");
                        cpb[i, j].Tag             = "tileTag";
                    }

                    cpb[i, j].BackgroundImageLayout = ImageLayout.Stretch;
                    Controls.Add(cpb[i, j]);
                }
            }
        }
Ejemplo n.º 15
0
        //Loading Block Matrix
        private void LoadBlocks()
        {
            int xAxis = 13;
            int yAxis = 5;

            remainingblocks = xAxis * yAxis;
            int BsWidth  = (Width - (xAxis - 5)) / xAxis;
            int BsHeight = (int)(Height * 0.3) / yAxis;

            cpb = new CustomPictureBox[yAxis, xAxis];

            for (int i = 0; i < yAxis; i++)
            {
                for (int j = 0; j < xAxis; j++)
                {
                    cpb [i, j] = new CustomPictureBox();

                    if (i == 0)
                    {
                        cpb[i, j].Hits = 3;
                    }
                    else if (i == 1 || i == 2)
                    {
                        cpb[i, j].Hits = 2;
                    }
                    else
                    {
                        cpb[i, j].Hits = 1;
                    }

                    cpb[i, j].Height = BsHeight;
                    cpb[i, j].Width  = BsWidth;

                    //Left y top
                    cpb[i, j].Left = j * BsWidth;
                    cpb[i, j].Top  = i * BsHeight;

                    //Block color
                    if (i == 0)
                    {
                        switch (cpb[i, j].Hits)
                        {
                        case 3:
                            cpb[i, j].BackgroundImage       = Image.FromFile("../../../Resources/Sprites/Blocks/Red.png");
                            cpb[i, j].BackgroundImageLayout = ImageLayout.Stretch;
                            break;

                        case 2:
                            cpb[i, j].BackgroundImage       = Image.FromFile("../../../Resources/Sprites/Blocks/Blue.png");
                            cpb[i, j].BackgroundImageLayout = ImageLayout.Stretch;
                            break;

                        case 1:
                            cpb[i, j].BackgroundImage       = Image.FromFile("../../../Resources/Sprites/Blocks/BrokenBlue.png");
                            cpb[i, j].BackgroundImageLayout = ImageLayout.Stretch;
                            break;
                        }
                    }
                    else if (i == 1 || i == 2)
                    {
                        switch (cpb[i, j].Hits)
                        {
                        case 2:
                            cpb[i, j].BackgroundImage       = Image.FromFile("../../../Resources/Sprites/Blocks/Blue.png");
                            cpb[i, j].BackgroundImageLayout = ImageLayout.Stretch;
                            break;

                        case 1:
                            cpb[i, j].BackgroundImage       = Image.FromFile("../../../Resources/Sprites/Blocks/BrokenBlue.png");
                            cpb[i, j].BackgroundImageLayout = ImageLayout.Stretch;
                            break;
                        }
                    }
                    else
                    {
                        switch (cpb[i, j].Hits)
                        {
                        case 1:
                            cpb[i, j].BackgroundImage       = Image.FromFile("../../../Resources/Sprites/Blocks/Green.png");
                            cpb[i, j].BackgroundImageLayout = ImageLayout.Stretch;
                            break;
                        }
                    }
                    cpb[i, j].Tag = "Block";
                    Controls.Add(cpb[i, j]);
                }
            }
        }
Ejemplo n.º 16
0
        private void LoadTiles()
        {
            int x = 10, y = 5;

            int pbWidth  = (Width - (x - 5)) / x;
            int pbHeight = (int)(Height * 0.3) / y;

            cpb = new CustomPictureBox[y, x];

            for (int i = 0; i < y; i++)
            {
                for (int j = 0; j < x; j++)
                {
                    cpb[i, j] = new CustomPictureBox();
                    //  no se como seria
                    // y ase ocmo pero umm esta complciado  yo no entiendo jaja



                    if ((i == 4 || i == 0) & (j % 2 == 0))
                    {
                        cpb[i, j].Hits = 2;
                    }
                    else if (i == 2)
                    {
                        cpb[i, j].Hits = 2;
                    }
                    else
                    {
                        cpb[i, j].Hits = 1;
                    }

                    cpb[i, j].Height = pbHeight;
                    cpb[i, j].Width  = pbWidth;


                    cpb[i, j].Left = j * pbWidth;
                    cpb[i, j].Top  = i * pbHeight + Scores.Height + 1;

                    int imageback = 0;

                    if (i % 2 == 0 && j % 2 == 0)
                    {
                        imageback = 3;
                    }
                    else if (i % 2 == 0 && j % 2 != 0)
                    {
                        imageback = 4;
                    }
                    else if (i % 2 != 0 && j % 2 == 0)
                    {
                        imageback = 4;
                    }
                    else
                    {
                        imageback = 3;
                    }


                    if ((i == 4 || i == 0) & (j % 2 == 0))
                    {
                        cpb[i, j].BackgroundImage = Image.FromFile("../../tiles/13.png");
                        cpb[i, j].Tag             = "blindedBlue";
                    }
                    else if (i == 2)
                    {
                        cpb[i, j].BackgroundImage = Image.FromFile("../../tiles/12.png");
                        cpb[i, j].Tag             = "blinded";
                    }
                    else
                    {
                        cpb[i, j].BackgroundImage = Image.FromFile("../../tiles/" + GenerateTiles() + ".png");
                        cpb[i, j].Tag             = "tileTag";
                    }

                    cpb[i, j].BackgroundImageLayout = ImageLayout.Stretch;

                    Controls.Add(cpb[i, j]);
                }
            }
        }
Ejemplo n.º 17
0
        /*
         * Método: private void LoadTiles()
         *
         * Función: carga los bloques del juego
         *
         * Descripción: Crea los bloques del juego usando la clase customPictureBox.
         * Agrega un color, resistencia y valor a cada bloque.
         */
        private void LoadTiles()
        {
            int xAxis = 10;
            int yAxis = 6;

            float pbHeight = (float)(Height * 0.25) / yAxis;
            float pbWidth  = (Width - xAxis) / xAxis;

            cpb = new CustomPictureBox[yAxis, xAxis];

            for (int i = 0; i < yAxis; i++)
            {
                for (int j = 0; j < xAxis; j++)
                {
                    blockCount++;
                    cpb[i, j] = new CustomPictureBox
                    {
                        Tag  = "blocks",
                        hits = 1,
                        BackgroundImageLayout = ImageLayout.Stretch,
                        Height = (int)pbHeight,
                        Width  = (int)pbWidth,
                        Left   = (int)(j * pbWidth),
                        Top    = (int)(i * pbHeight + 70)
                    };

                    //características especiales
                    switch (i)
                    {
                    case 0:
                        cpb[i, j].hits            = 2;
                        cpb[i, j].BackgroundImage = Resources.Tile_silver;
                        cpb[i, j].addedScore      = 50;
                        break;

                    case 1:
                        cpb[i, j].BackgroundImage = Resources.Tile_red;
                        cpb[i, j].addedScore      = 90;
                        break;

                    case 2:
                        cpb[i, j].BackgroundImage = Resources.Tile_yellow1;
                        cpb[i, j].addedScore      = 120;
                        break;

                    case 3:
                        cpb[i, j].BackgroundImage = Resources.Tile_blue;
                        cpb[i, j].addedScore      = 100;
                        break;

                    case 4:
                        cpb[i, j].BackgroundImage = Resources.Tile_violet;
                        cpb[i, j].addedScore      = 110;
                        break;

                    case 5:
                        cpb[i, j].BackgroundImage = Resources.Tile_green;
                        cpb[i, j].addedScore      = 80;
                        break;
                    }
                    Controls.Add(cpb[i, j]);
                }
            }
        }
        private void LoadTiles()
        {
            int xAxis = 10, yAxis = 5;

            int pbWidth  = (Width - (xAxis - 5)) / xAxis;
            int pbHeight = (int)(Height * 0.3) / yAxis;

            cpb = new CustomPictureBox[yAxis, xAxis];

            for (int i = 0; i < yAxis; i++)
            {
                for (int j = 0; j < xAxis; j++)
                {
                    cpb[i, j] = new CustomPictureBox();

                    if (i == 4)
                    {
                        cpb[i, j].Hits = 2;
                    }
                    else
                    {
                        cpb[i, j].Hits = 1;
                    }

                    // Seteando el tamano
                    cpb[i, j].Height = pbHeight;
                    cpb[i, j].Width  = pbWidth;

                    // Posicion de left, y posicion de top
                    cpb[i, j].Left = j * pbWidth;
                    cpb[i, j].Top  = i * pbHeight + scorePanel.Height + 1;

                    int imageBack = 0;

                    if (i % 2 == 0 && j % 2 == 0)
                    {
                        imageBack = 3;
                    }
                    else if (i % 2 == 0 && j % 2 != 0)
                    {
                        imageBack = 4;
                    }
                    else if (i % 2 != 0 && j % 2 == 0)
                    {
                        imageBack = 4;
                    }
                    else
                    {
                        imageBack = 3;
                    }

                    if (i == 4)
                    {
                        cpb[i, j].BackgroundImage = Image.FromFile("../../Img/tb1.png");
                        cpb[i, j].Tag             = "blinded";
                    }
                    else
                    {
                        cpb[i, j].BackgroundImage = Image.FromFile("../../Img/" + imageBack + ".png");
                        cpb[i, j].Tag             = "tileTag";
                    }

                    cpb[i, j].BackgroundImageLayout = ImageLayout.Stretch;

                    Controls.Add(cpb[i, j]);
                }
            }
        }
Ejemplo n.º 19
0
        //This function, permits fill the platform with bricks, and pick the photos from code
        private void LoadTiles()
        {
            try
            {
                int xAxis = 10;
                int yAxis = 5;

                int PlatFormHeight = (int)(Height * 0.3) / yAxis;
                int PlatFormWidth  = (Width - (xAxis - 5)) / xAxis;

                cpb = new CustomPictureBox[yAxis, xAxis];

                for (int i = 0; i < yAxis; i++)
                {
                    for (int j = 0; j < xAxis; j++)
                    {
                        cpb[i, j] = new CustomPictureBox();

                        if (i == 2)
                        {
                            cpb[i, j].Hits = 2;
                        }
                        else
                        {
                            cpb[i, j].Hits = 1;
                        }

                        //Setting the size
                        cpb[i, j].Height = PlatFormHeight;
                        cpb[i, j].Width  = PlatFormWidth;

                        //Position from Left, Position from Top
                        cpb[i, j].Left = j * PlatFormWidth;
                        cpb[i, j].Top  = i * PlatFormHeight + scorePanel.Height + 1;

                        int imageBack = 0;

                        if (i % 2 == 0 && j % 2 == 0)
                        {
                            imageBack = 3;
                        }
                        else if (i % 2 == 0 && j % 2 != 0)
                        {
                            imageBack = 4;
                        }
                        else if (i % 2 != 0 && j % 2 == 0)
                        {
                            imageBack = 4;
                        }
                        else
                        {
                            imageBack = 3;
                        }

                        //Generar un numero aleatorio para que sean blindados...
                        //Tener cuidado con los numero aleatorios, necesitan seed que se tome con el tiempo
                        if (i == 2)
                        {
                            cpb[i, j].BackgroundImage = Image.FromFile("../../Textures/Tileblinded.png");
                            cpb[i, j].Tag             = "blinded";
                        }
                        else
                        {
                            cpb[i, j].BackgroundImage = Image.FromFile("../../Textures/" + imageBack + ".png");
                            cpb[i, j].Tag             = "tileTag";
                        }

                        cpb[i, j].BackgroundImageLayout = ImageLayout.Stretch;

                        Controls.Add(cpb[i, j]);
                    }
                }
            }
            catch (Exception exceptionGameOver)
            {
                MessageBox.Show("The game has end");
            }
        }