我已经制定了大部分代码并且有几个游戏类。我现在坚持的一点是,它如何绘制实际的Connect 4网格。谁能告诉我这个for
循环有什么问题?我没有得到任何错误,但网格并未出现。我正在使用C#。连接4 C#(如何绘制网格)
private void Drawgrid()
{
Brush b = Brushes.Black;
Pen p = Pens.Black;
for (int xCoor = XStart, col = 0; xCoor < XStart + ColMax * DiscSpace; xCoor += DiscSpace, col++)
{
// x coordinate beginning; while the x coordinate is smaller than the max column size, times it by
// the space between each disc and then add the x coord to the disc space in order to create a new circle.
for (int yCoor = YStart, row = RowMax - 1; yCoor < YStart + RowMax * DiscScale; yCoor += DiscScale, row--)
{
switch (Grid.State[row, col])
{
case GameGrid.Gridvalues.Red:
b = Brushes.Red;
break;
case GameGrid.Gridvalues.Yellow:
b = Brushes.Yellow;
break;
case GameGrid.Gridvalues.None:
b = Brushes.Aqua;
break;
}
}
MainDisplay.DrawEllipse(p, xCoor, yCoor, 50, 50);
MainDisplay.FillEllipse(b, xCoor, yCoor, 50, 50);
}
Invalidate();
}
@John Rasch - 对不起,我们都似乎在编辑。我会停下来。 – 2010-03-11 18:41:05