public Form1(string idNo) { InitializeComponent(); this.Text = "Game Window "+idNo; label1.Visible = false; label2.Visible = false; label3.Visible = false; label4.Visible = false; triggerLabel.Visible = false; gameRunning = false; aircraftCarrierPlaced = false; battleshipPlaced = false; submarinePlaced = false; destroyerPlaced = false; patrolBoatPlaced = false; mouseDown = false;// keep writing not used, should honestly just get rid of it (but don't) rotateNext = false; rotatePrevious = false; currentShipCode = 0; playerGridSquares = new GridSquare[10, 10]; enemyGridSquares = new GridSquare[10, 10]; panelSize.X = playerPanel.Width;// gets width of the player panel panelSize.Y = playerPanel.Height;// gets height of the player panel xGridSquareSize = (panelSize.X / 10);//individual panel x size yGridSquareSize = (panelSize.Y / 10);//individual panel y size playerDraw = new Drawer(playerPanel, xGridSquareSize, yGridSquareSize); //this handles all graphics. repeating it in here got ugly. playerPanel.Enabled = false;//set to false to prevent input before setup. Set to false again on game end pls. enemyDraw = new Drawer(enemyPanel, xGridSquareSize, yGridSquareSize); enemyPanel.Enabled = false; }
private void DrawGrid(Drawer draw, GridSquare[,] GridSquares) { for (int i = 1; i < 10; i++) { //vertical lines draw.VerticalLine(draw.with.blackPen, panelSize, i); //horizontal lines draw.HorizontalLine(draw.with.blackPen, panelSize, i); } // filling a 2D array with blank gridSquares // these will store information about that square for (int x = 0; x < 10; x++) { for (int y = 0; y < 10; y++) { GridSquares[x, y] = new GridSquare(new Point(x * xGridSquareSize, y * yGridSquareSize), new Point((x * xGridSquareSize) + xGridSquareSize, (y * yGridSquareSize) + yGridSquareSize)); } } }