c# 俄罗斯方块的一些小问题。。望详细解答 本人是新手。。 20
privatevoidForm1_Paint(objectsender,PaintEventArgse)...{Graphicsformgs=e.Graphics;for...
private void Form1_Paint(object sender, PaintEventArgs e)
...{
Graphics formgs = e.Graphics;
formgs.FillRegion(bbrush, new Region(new Rectangle(x1, y1, x2 - x1 + 1, y2 - y1 + 1)));
for (int i = 0; i < rows; i++)//窗口被拖动、隐藏等时,需要重绘
for (int j = 0; j < cols; j++)
...{
if (urect[i, j].flag)
formgs.FillRectangle(wbrush, urect[i, j].rect);
}
/**/////重绘下一次将要出现的next方块
formgs.FillRectangle(bbrush, new Rectangle(300 + 20 * mymoder[nextIndex].x1, 40 + 20 * mymoder[nextIndex].y1, 19, 19));
formgs.FillRectangle(bbrush, new Rectangle(300 + 20 * mymoder[nextIndex].x2, 40 + 20 * mymoder[nextIndex].y2, 19, 19));
formgs.FillRectangle(bbrush, new Rectangle(300 + 20 * mymoder[nextIndex].x3, 40 + 20 * mymoder[nextIndex].y3, 19, 19));
formgs.FillRectangle(bbrush, new Rectangle(300 + 20 * mymoder[nextIndex].x4, 40 + 20 * mymoder[nextIndex].y4, 19, 19));
formgs.Dispose();
}
private void Form1_Load(object sender, EventArgs e)
...{
initRect();
initMymoder();
wbrush = new SolidBrush(Color.White);
bbrush = new SolidBrush(Color.Black);
gbrush = new SolidBrush(Color.Gainsboro);
mytimer.Enabled = true;
score_time_timer.Enabled = true;
rand = new Random();
nextIndex = rand.Next(0, 19);
rebuild = true;//用于判断是不是最新构建的模型,在tick中会用到
}
private void initRect()
...{
urect = new unitrect[rows, cols];
int unit = (x2 - x1) / cols;
for (int i = 0; i < rows; i++)
for (int j = 0; j < cols; j++)
...{
urect[i, j].flag = false;
urect[i, j].rect = new Rectangle(x1 + unit * j + 1, y1 + unit * i + 1, unit - 1, unit - 1);
}
想知道这段代码是什么意思。。有什么作用。。我是新手。。啥也不懂。。所以麻烦解释的细一些。。。谢谢 展开
...{
Graphics formgs = e.Graphics;
formgs.FillRegion(bbrush, new Region(new Rectangle(x1, y1, x2 - x1 + 1, y2 - y1 + 1)));
for (int i = 0; i < rows; i++)//窗口被拖动、隐藏等时,需要重绘
for (int j = 0; j < cols; j++)
...{
if (urect[i, j].flag)
formgs.FillRectangle(wbrush, urect[i, j].rect);
}
/**/////重绘下一次将要出现的next方块
formgs.FillRectangle(bbrush, new Rectangle(300 + 20 * mymoder[nextIndex].x1, 40 + 20 * mymoder[nextIndex].y1, 19, 19));
formgs.FillRectangle(bbrush, new Rectangle(300 + 20 * mymoder[nextIndex].x2, 40 + 20 * mymoder[nextIndex].y2, 19, 19));
formgs.FillRectangle(bbrush, new Rectangle(300 + 20 * mymoder[nextIndex].x3, 40 + 20 * mymoder[nextIndex].y3, 19, 19));
formgs.FillRectangle(bbrush, new Rectangle(300 + 20 * mymoder[nextIndex].x4, 40 + 20 * mymoder[nextIndex].y4, 19, 19));
formgs.Dispose();
}
private void Form1_Load(object sender, EventArgs e)
...{
initRect();
initMymoder();
wbrush = new SolidBrush(Color.White);
bbrush = new SolidBrush(Color.Black);
gbrush = new SolidBrush(Color.Gainsboro);
mytimer.Enabled = true;
score_time_timer.Enabled = true;
rand = new Random();
nextIndex = rand.Next(0, 19);
rebuild = true;//用于判断是不是最新构建的模型,在tick中会用到
}
private void initRect()
...{
urect = new unitrect[rows, cols];
int unit = (x2 - x1) / cols;
for (int i = 0; i < rows; i++)
for (int j = 0; j < cols; j++)
...{
urect[i, j].flag = false;
urect[i, j].rect = new Rectangle(x1 + unit * j + 1, y1 + unit * i + 1, unit - 1, unit - 1);
}
想知道这段代码是什么意思。。有什么作用。。我是新手。。啥也不懂。。所以麻烦解释的细一些。。。谢谢 展开
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询