Simon

Simon

  • NA
  • 10
  • 0

attempt at game of life, drawing the grid and filling the cells

Nov 30 2007 1:01 PM
hi guys, iv just started to create a grid for my "game of life", basically what i want to do is on mouse down i want the corresponding cell to fill with the color selected for my brush. i have drawn the grid as follows:

 {
       
           
            Pen p = new Pen(Color.Black);
            g1 = Graphics.FromImage(grid);

           
             

           
            for (int i = 0; i < 300; i = i + 50) ;
       
            for (int i = 10; i < 300; i = i + 20)
            {
                g1.DrawLine(p, 10, i, 290, i);
            }
            for (int x = 10; x < 300; x = x + 20)
            {
                g1.DrawLine(p, x, 10, x, 290);
            }
            
            
        }
can anyone help me on how to fill the rectangles with my chosen color when clicked on? do i need to use DrawRectangle instead of DrawLine for the basic grid?

any help is great, thanks!!


Answers (8)