Skip to main content
GameDev.net gamedev.net
🔒 Locked

drawing board

Started by GravtyKlz Mar 1, 2003 at 7:17 PM 1 replies 250+ views
Original Post
GravtyKlz
GravtyKlz
Im trying to draw a checkers board, but for some reason the first column of blocks are a little wider than the rest
for(i=0;i<8;i++)
	{
	for(j=0;j<8;j++)
        {	
	      if (i == 0 || i == 2 || i == 4 || i == 6 || i == 8)
		{
			if (j == 0)
				fl = 0;
			else 
				fl +=200;
			
			ft = (71*i);
		
			fr = fl + 100;
			fb = ft+71;
			
			rc.left = fl;
			rc.right = fr;
			rc.bottom = fb;
			rc.top = ft;
			FillRect(hdc, &rc, black_brush);
		}
		else
		{
			if (j == 0)
				fl = 100;
			else 
				fl +=200;
			
			ft = (71 * i);
			fr = fl +100;
    		       fb = ft +71;
			rc.left = fl;
			rc.right = fr;
			rc.bottom = fb;
			rc.top = ft;
			FillRect(hdc, &rc, black_brush);
		}
	}
}
 
I initially tried the if statement as if(i%2 || i == 0) but it didnt work so I did it that long way. Anyways the board comes out perfect except for that first column.
GravtyKlz
GravtyKlz
I found my own problem. The edges of the screen are black and that makes all the blocks on the edges look bigger. I fixed it by making a white border around the window. I''m still wondering why if(i%2 || i == 0) didnt work though.
evillive2
evillive2
quote:

I''m still wondering why if(i%2 || i == 0) didnt work though.



I think you want:

if ( i % 2 == 0 )

Evillive2

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.