private void Form1_Paint(object sender, PaintEventArgs e) { int yoffset = 50; if (paintIt) { // Just so I can get a good visual on it going to precaculate the numbers int xStride = rXmax; int zStride = xStride * rYmax; // Precaculate the last line in a floor and the last floor int zLast = rData.Length - zStride; int yLast = zStride - xStride; int bmpWidth = rXmax * (20 + 2); // With of the square + 2 for the lin left and rigg int bmpLength = rYmax * (20 + 2); e.Graphics.Clear(Color.White); for (int i = 0; i < rBlocks.Length; i++) { redstoneObj temp = rGrid[i]; if (temp.Z == currentZ) { e.Graphics.DrawImage(temp.getBitmap(rData[i]), temp.X * 20, temp.Y * 20 + yoffset); e.Graphics.DrawRectangle(Pens.Black, temp.X * 20, temp.Y * 20 + yoffset, 20, 20); } } } }
private Bitmap CreateGrid(int zLevel) { // Just so I can get a good visual on it going to precaculate the numbers int xStride = rXmax; int zStride = xStride * rYmax; int bmpWidth = rXmax * 20; // With of the square + 2 for the lin left and rigg int bmpLength = rYmax * 20; Bitmap buffer = new Bitmap(bmpWidth, bmpLength, System.Drawing.Imaging.PixelFormat.Format32bppArgb); Graphics g = Graphics.FromImage(buffer); g.Clear(Color.White); for (int i = 0; i < rBlocks.Length; i++) { redstoneObj temp = rGrid[i]; if (temp.Z == zLevel) { g.DrawImage(temp.getBitmap(rData[i]), temp.X * 20, temp.Y * 20); int nZ = zLevel + 1 > rZmax ? rZmax : zLevel + 1; // if (rGrid[i + zStride].bType == blockType.RedstoneWire) // g.DrawImage(rGrid[i + zStride].getBitmap(rData[i + zStride]), temp.X * 20, temp.Y * 20); g.DrawRectangle(Pens.Black, temp.X * 20, temp.Y * 20, 20, 20); } } return(buffer); }