Tag: rectangles

使用XNA在游戏窗口中显示矩形

我想将我的游戏网格划分为一个矩形arrays。 每个矩形为40×40,每列有14个矩形,总共25列。 这涵盖了560×1000的游戏区域。 这是我设置的代码,用于在游戏网格上创建第一列矩形: Rectangle[] gameTiles = new Rectangle[15]; for (int i = 0; i <= 15; i++) { gameTiles[i] = new Rectangle(0, i * 40, 40, 40); } 我很确定这是有效的,但当然我无法确认它,因为矩形不会在屏幕上呈现让我亲身看到它们。 我想为调试目的做的是渲染边框,或用颜色填充矩形,这样我就可以在游戏本身上看到它,只是为了确保它有效。 有没有办法让这种情况发生? 或者任何相对简单的方法,我可以确保这有效吗? 非常感谢你。

奇怪地使用Graphics.FillPath绘制GraphicsPath

我编写了一些代码,它创建了一个圆角矩形GraphicsPath ,基于自定义结构BorderRadius (允许我定义矩形的左上角,右上角,左下角和右下角),以及初始的Rectangle本身: public static GraphicsPath CreateRoundRectanglePath(BorderRadius radius, Rectangle rectangle) { GraphicsPath result = new GraphicsPath(); if (radius.TopLeft > 0) { result.AddArc(rectangle.X, rectangle.Y, radius.TopLeft, radius.TopLeft, 180, 90); } else { result.AddLine(new System.Drawing.Point(rectangle.X, rectangle.Y), new System.Drawing.Point(rectangle.X, rectangle.Y)); } if (radius.TopRight > 0) { result.AddArc(rectangle.X + rectangle.Width – radius.TopRight, rectangle.Y, radius.TopRight, radius.TopRight, 270, 90); } else { […]