开发者

Block busting algorithm needed (akin to Bomberman)

Currently, I am just using two bitvectors, one for red blocks and one for blue. The blocks are stacked atop on another in a 10x10 grid. When an explosion occurs from a bomb for only red blocks in a vertical direction, I just do simple math and check the bitvector for a hit so the worst I have to deal with is 10 checks and a fast look up.

Now, I want to make it so a bomb can destroy all connected red blocks from the start block (connected meaning vertical, horizontal or diagonal from one another).

What would be the best away to approach this? The distribution is random but usually something like 40/60. The things which I have to work with are as I said, the bitvector, block ids and what kind of blocks they are based on their interface.

Is it best just to check 1 or 2 outer rings of blocks every frame on a 开发者_开发知识库seperate thread to partition the work (so 20 checks per frame) or is there a more elegant way of doing this?


Now, I want to make it so a bomb can destroy all connected red blocks from the start block

Sounds like a job for the flood fill algorithm.

The distribution is random but usually something like 40/60.

I honestly don't understand what you mean.

As for implementation details, those will differ per language.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜