private void printMap() { bool[,] map = game.getMap(); System.Drawing.Image img = System.Drawing.Image.FromFile(startupPath + fieldImagePath); // to determine dimensions fieldWidth = img.Width; // px fieldHeight = img.Height; int height = game.getMapHeight(); // units int width = game.getMapWidth(); for (int x = 0; x < width; x++) { for (int y = 0; y < height; y++) { imageMap[x, y] = new Square(); imageMap[x, y].Image = img; imageMap[x, y].Width = fieldWidth; imageMap[x, y].Height = fieldHeight; imageMap[x, y].Location = new System.Drawing.Point(margin + fieldWidth * x, margin + fieldHeight * y); imageMap[x, y].MouseEnter += infield; imageMap[x, y].MouseLeave += outfield; imageMap[x, y].MouseClick += clickfield; imageMap[x, y].x = x; imageMap[x, y].y = y; this.Controls.Add(imageMap[x, y]); } } }