How to implement a Worms style destructible terrain in XNA?

前端 未结 4 870
轮回少年
轮回少年 2021-01-30 18:16

I want to prototype an idea for a game I have. The idea for this game is that the player will dig through the ground, creating tunnels and finding treasure.

I\'m looking

4条回答
  •  忘了有多久
    2021-01-30 19:11

    There are two possibilties, eighter one work, but it depends on XNA how easy it is to implement:

    • Like others suggested, bitmap masking. You keep a bitmap of all "ground" pixels and all "air" pixels. If you have gravity; a character can't fall through ground, while it can fall through air.
    • Vector geometry. You start with a rectangular "ground", and hold a list of "removed" ground, which creates air. This geometry is very simple to edit: just append a circle or similar to the list, and update the graphics. I don't know whether XNA has vector & shape abilities; but it should be easy to create geometry with these two things, and later apply a texture or similar. Also, this can be easy to optimize, by keeping a cached version of the rendered landscape, and only update the cache of the bounding-box of the newly added "air". This solution requires a bit more math though.

提交回复
热议问题