竞赛游戏中的强化

发布于 2024-09-27 18:59:25 字数 112 浏览 0 评论 0原文

我遇到了一个问题:我需要使用碰撞检测向赛车游戏添加电源。 所以我画了powerup,但问题是:它必须在每5轮后绘制一次,并且需要随机放置在轨道上。

有人有什么好的建议吗?

谢谢。

I've got a problem: i need to add a powerup to a racegame, using collision detection.
so i drawed the powerup, but the problem is: It has to be drawn after every 5 rounds and it needs to be placed ramdomly on the track.

Someone with any good advice?

Thanks.

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

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

发布评论

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

评论(1

朮生 2024-10-04 18:59:25

这有点模糊。所以这是我最好的答案。

您可能想要使用 c# Random 类, 这里是文档

对于一个简单的游戏,使用矩形碰撞应该是您所需要的(我假设这就是您正在使用的) - 如果您想随机生成加电位置,您将需要创建一个带有随机生成器的新 Vector2(通电位置)。

您可以使用 Next 函数传入低值和高值变量 - 您需要配置您希望加电显示的范围。

另一方面,作为游戏设计师,我的建议告诉我,随机定位的能量提升并不总是可行的。这使得控制游戏流程和平衡变得更加困难,并且很容易导致最终产品有缺陷。

所以我的建议是一组可能的武器生成点的硬编码 - 使用随机生成器来选择一个来放置。

Thats a bit vague. So here is my best shot at an answer.

You would want to use the c# Random class, here are the docs

For a simple game, using rectangular collision should be all you need (I assume thats what you are using) - If you want to randomly generate the power-up position, you will want to create a new Vector2 (the powerups position) with the random generator.

You can use the Next function, to pass in a low, and high variable - which you would need to configure the the bounds you wish the powerup to appear.

My advice as a game designer on the other hand, tells me that randomly located power-ups aren't always the go. It makes it harder to control the games flow and balance, and can very easily result in a flawed final product.

So my advice is a hard coded set of possible weapon spawn points - using a random generator to pick one to place.

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