0
Reply

Painting a grind in GDI+

Matej Jazbinsek

Matej Jazbinsek

Aug 8 2005 6:47 PM
1.7k

Hello, my problem is how do draw an grind with GDI+, i need a grid for my furst game so the 
object will be able to move in cells. that was my way:

private void GrindPaint(object sender, PaintEventArgs pea)

{

Graphics gfx = pea.Graphics;

int space = 2,cwidth = 10, cheight =10, amount =30;

Pen pen = new Pen(Color.Black);

int cx=1,cy=1;

for(int j = 0; j<amount; j++)

{

cx = 1;

for(int i =0; i<amount; i++)

{

gfx.DrawRectangle(pen,cx,cy,cwidth ,cheight);

cx = (cx+cwidth+space);

}

cy =(cy+cheight+space);

}

}

//amount is amount of cells in x and y
//space is cellspacing space from one cell to another
//cx and cy are cordinates of one rectangle or cell

My question is , is there another, better way or easier

tnx for help!!