如何制作“矩阵”对于拼图泡泡?
嘿伙计们,我正在尝试制作一个拼图泡泡克隆,但我对如何处理背景内容感到困惑。主要是因为线条不匹配(即:一个气泡不是有另一个没有顶部的气泡,一个在左上角,一个在右上角,而是一个在左上角,一个在右上角)右上角 http://dl.dropbox.com/u/680263/puzzle_bobble_2.jpg< /a>)以及如何确定射击时哪些气泡会破裂(以及哪些气泡会掉落),而无需使用会让我的 i7 哭泣的蛮力算法。
谁能就如何处理这个问题提出一些建议?
Hey guys, I'm trying to make a puzzle bubble clone but I'm stumped on how to handle the background stuff. Mostly with the fact that the lines don't match up (i.e: instead of a bubble having another no top of it, one on the upper-left and one on the upper-right, it has one on the upper left and one on the upper right http://dl.dropbox.com/u/680263/puzzle_bobble_2.jpg) and how to determine which bubbles pop when I make shot (and which fall) without making a brute-force algorithm that would make my i7 cry.
Can anyone give some sugestions on how to handle this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
它必须是多维数组吗?像这样的“气泡”结构怎么样:
然后,当您弹出一个给定的气泡时,您可以沿双向和横向双向遍历树,并摆脱最终未附着在顶部的任何气泡“岛”墙。请记住,气泡可以由其他气泡的“手臂”从侧面或下方支撑。
我怀疑与使用多维数组相比,这存储效率较低,但速度效率更高。
Does it have to be a multi-dimensional array? How about a "bubble" structure like this:
Then when you pop a given bubble, you can do a tree traverse down both ways and sideways both ways, and get rid of any "island" of bubbles that are not eventually attached to the top wall. Bear in mind bubbles can be supported by "arms" of other bubbles from the side or below.
I suspect that this is less storage efficient, but more speed efficient, than using a multi-dimensional array.
我已经用Lua用表格实现了这个泡泡拼图游戏,
http://www.youtube.com/watch?v=rD0fQVSj_7w& ;list=UUlKVS4jFzSMXF9l6Jw1uoaw&feature=plcp
你可以在这里看到代码:
https://gist.github.com/1725481
您可以使用二维拼图板来使用此实现表:
用 C 代码编写很简单......
I have implemented this Puzzle Bubble game in Lua with tables,
http://www.youtube.com/watch?v=rD0fQVSj_7w&list=UUlKVS4jFzSMXF9l6Jw1uoaw&feature=plcp
you can see the code here:
https://gist.github.com/1725481
You can use this implementation for the puzzle board using a bidimensional table:
and write in C code is simple...
我不认为在益智泡泡游戏中使用这种数据结构是一个好主意,因为它需要更新棋盘中所有泡泡的大量指针。
就拿这个简单的例子来说:
当你有两个或三个相同颜色的气泡和两个不同颜色的气泡时,所有气泡都已经设置在板上;下一个发射的气泡是第一种颜色,它击中了三个气泡,您必须首先将气泡附加到其位置,然后更新所有指针。
然后,您必须遍历所有这些指针来搜索气泡姐妹(相同颜色和相邻),但使用这种数据结构更难找到,因为您必须构建多个具有很多条件的递归函数。
另外你还必须知道第一行的气泡比下一行多,即偶数行有 7 个(例如),奇数行有 6 个气泡。
使用表格时,您必须考虑这些情况,这也很复杂。
也许,另一种实现可能是使用一棵树,其中根具有第一行气泡作为子节点。
I don't think that using this data-structure in a puzzle bubble game is a good idea, because it needs to update a lot of pointers for all the bubbles in the board.
Just take this simple case:
when you have two or three bubbles of the same colour and 2 with different colors, all already set in the board; and the next bubble launched is of the first color, it hits the group of three, you have first to attach the bubble in its place and then update all the pointers.
then, you have to go through all these pointers searching for bubble sisters (same colour and adjacents) but with this datastructure is much harder to find because you have to build several recursive functions with a lot of conditions.
Also you have to know that the first line of bubbles have more than the next, it is, even rows have 7 (for example) and odd rows have 6 bubbles.
With a table you have to consider these cases, there is also a complexity here.
Maybe, another implementation could be to use a tree where the root has the first line of bubbles as child nodes.