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]); } } }
//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]); } } }
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]); } } }