如何在XNA中实现Worms风格的可破坏地形?

发布于 2024-08-18 08:28:57 字数 414 浏览 5 评论 0原文

我想为我的游戏制作一个想法原型。这款游戏的理念是,玩家将挖掘地面,创造隧道并寻找宝藏。

我正在寻找创建“蠕虫式”地形,为在隧道中徘徊和跳跃的玩家提供碰撞检测。在这些图片中可以看到这种类型的动态地形的示例。 示例 1 Example 2

我的问题是如何实现这种类型的最佳方法可破坏的地形?我正在使用 XNA 游戏工作室。

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 to create 'worms style' terrain, with collision detection for the player wandering and jumping around the tunnels. Examples of this type of dynamic terrain can be seen in these pictures.
Example 1

Example 2

My question is how is the best way to implement this type of destructible terrain? I am using XNA game studio.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

宛菡 2024-08-25 08:28:57

Riemer 与他在 XNA 中开发的游戏有类似的方法,炮弹会导致地形被“破坏”,并且先前位于所述地形上的任何道具都会相应移动。

它需要根据您的需求进行重构和改进,但这只是一个开始。

Riemer 也有很多其他方面的教程可供选择。

http://www.riemers.net/eng/Tutorials/ XNA/Csharp/Series2D/Adding_craters.php

Riemer has a similar approach to a game he developed in XNA, cannon shells cause the terrain to be "destroyed" and any props that were previously on said terrain are moved accordingly.

It needs to be refactored and improved for your needs but it's a start.

Riemer has a good selection of tutorials for other things too.

http://www.riemers.net/eng/Tutorials/XNA/Csharp/Series2D/Adding_craters.php

蓝戈者 2024-08-25 08:28:57

有两种可能性,八种可行,但这取决于 XNA 实现起来有多容易:

  • 像其他人建议的那样,位图掩码。您保留所有“地面”像素和所有“空气”像素的位图。如果你有重力;角色不能从地面掉落,但可以从空中掉落。
  • 矢量几何。您从一个矩形“地面”开始,并保存一个“移除”地面的列表,这会产生空气。该几何图形的编辑非常简单:只需在列表中添加一个圆或类似的图形,然后更新图形即可。我不知道XNA是否有向量&塑造能力;但用这两个东西创建几何体应该很容易,然后应用纹理或类似的东西。此外,通过保留渲染景观的缓存版本,并且仅更新新添加的“空气”的边界框的缓存,这可以很容易优化。不过,这个解决方案需要更多的数学知识。

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.
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文