我正在尝试创建一个 hextiled map ,如下所示:
http://files.slembcke.net/misc/procedural/hex_tiles.png
但是我在将列表中的图 block X(行)和 Y(列)索引转换为屏幕位置时遇到了一些问题:
public static Vector2 GetDisplayCoordOfTile(GameTile t, Texture2D texture)
{
Vector2 screenPadding = new Vector2(2, 2);
float ypos = (t.Column * (texture.Height + 2)) - (t.Row * texture.Height / (float)2) + screenPadding.Y;
float xpos = (t.Row * (texture.Width)) + screenPadding.X;
return new Vector2(xpos, ypos);
}
有没有人知道哪里出了问题,我无法理解这个想法,因为坐标系不同于常规数组中的思考
最佳答案
这里有一个关于如何绘制六边形 map 的很棒的教程: http://www.xnaresources.com/default.asp?page=Tutorial:TileEngineSeries:3
此外,您可能会在此处提出与游戏开发相关的问题以获得更多帮助:https://gamedev.stackexchange.com/
关于c# - 给定索引和纹理大小的位置,我如何计算我的 hextiles 位置?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15720088/