竞赛游戏中的强化
我遇到了一个问题:我需要使用碰撞检测向赛车游戏添加电源。 所以我画了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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这有点模糊。所以这是我最好的答案。
您可能想要使用 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.