如何绘制/管理六边形网格?
我读过这篇文章: 在 C 中生成/创建六边形网格 。不过貌似作者和回答者都已经放弃了。
√(hexagonSide - hexagonWidth * hexagonWidth)
:hexagonSide 和 hexagonWidth 是什么?是不是会< 0(因此无法计算平方根)。
而且,我可以将六边形放入矩形吗?我需要创建一个像这样的网格:
还有一件事,我如何安排我的数组来存储数据,以及获取哪些单元格紧邻一个单元格?
我从来没有学过六边形,所以我对此一无所知,但我可以很容易地学习新东西,所以如果你能解释或给我一个线索,我可以自己做。
I've read this article: generating/creating hexagon grid in C . But look like both the author and answerer have already abandoned it.
√(hexagonSide - hexagonWidth * hexagonWidth)
: What's hexagonSide and hexagonWidth? Isn't it will < 0 (so square root can't be calculated).
And, can I put a hexagon into a rectangle? I need to create a grid like this:
One more thing, how can I arrange my array to store data, as well as get which cells are next to one cell?
I have never been taught about hexagon, so I know nothing about it, but I can easily learn new thing, so if you can explain or give me a clue, I may do it myself.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
表示数据的一种方法是这样考虑:
破折号是空位置——它们存在于数组中,但不表示任何六边形。这里,六边形 m 连接到六边形 c、g、h、q、r、w。一旦您对这种表示方式感到满意,您可以通过删除空位置来使其更加紧凑:
六边形 m 仍然连接到六边形 c、g、h、q、r、w,只是有点难以看到。
更新阅读:http:// /www-cs-students.stanford.edu/~amitp/game-programming/grids/
One way to represent the data would be to think of it like this:
The dashes are null locations -- they exist in the array, but do not represent any hexagon. Here, hexagon m is connected to hexagons c, g, h, q, r, w. Once you are ok with that representation, you can make it more compact by removing the null locations:
Hexagon m is still connected to hexagons c, g, h, q, r, w, it's just a little harder to see.
Update Read this: http://www-cs-students.stanford.edu/~amitp/game-programming/grids/
这就是我绘制六边形的方法:
This is how I draw the hexagon:
您可以查看https://code.google.com/p/jhexed/我想这可以是一个例子
you can take a look at https://code.google.com/p/jhexed/ I guess it can be an example