在游戏中设计和加载关卡

发布于 2024-10-10 19:08:34 字数 1435 浏览 0 评论 0原文

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

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

发布评论

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

评论(3

国粹 2024-10-17 19:08:34

你可以从老式的方法开始:让小怪静止。您的地图数据可以包含生物、它们的位置、它们的类型以及它们的移动方式。精心设计的地图可以让游戏变得非常具有挑战性和乐趣。

对于人工智能来说,通常需要多种算法的混合。假设你正在做类似单人自由模式星际争霸的事情,人工智能可以结合启发式(即预先制定的策略,例如用压倒性的力量淹没玩家群,创建第二基地)和最小-最大算法决策(即在遭遇战中,像在国际象棋中那样消灭最具威胁的单位)。这是一个有趣的话题,也是许多程序员/科学家职业生涯的基础。

You can start with the old-fashioned way: make mobs stationary. Your map data can contain mobs, where they are located, what type they are, and how they move. A carefully designed map can make the game very challenging and fun.

For AI's, typically a hybrid of multiple algorithms will be necessary. Say if you're doing something like a single player free-mode StarCraft, the AI can be combination of heuristics (i.e. pre-cooked strategy such as flooding player base with overwhelming power, creating second base) and min-max algorithm decision (i.e. in an encounter, take out the most threatening unit as you would do in chess). That is an interesting topic and is also the foundation of many fellow programmers'/scientists' career.

终弃我 2024-10-17 19:08:34

嗯,这通常是你为了满足自己的需要而做的事情。没有一种正确的方法。

对于我几年前开发的一款 3D 平台游戏,我设计了编辑器和游戏逻辑。游戏逻辑全部是 C++ 层次结构,每个对象都有能力将消息传递给其他对象。要激活打开门的杠杆,我只需设置一个简单的“触发区域”,它本身就是一个逻辑对象,简单地检查用户是否在球体内部(由于关卡被组织成某些“区域”,我不需要检查不在我当前区域的触发器)。然后触发器将激活控制杆(这将启动动画)。然后设置杠杆以在拉动门后启动门。由于任何对象都可以是触发器,因此将触发器链接在一起很简单。我什至可以将触发器分配给某些点。例如AnimationBegin、AnimationEnd,在一定时间之后或者可以将其设置为动画中的特定关键帧。由于每个对象都可以有这样的触发器,因此可以轻松设计编辑器以允许您选择触发事件,然后设置触发器发生时激活哪个对象。当然,这些触发器可能会以动画为关键发生,这使我能够执行诸如同步对象移动之类的事情以防止更令人讨厌的陷阱......

这只是一种方法,它非常适合我们需要的东西。有许多不同的方法可以解决这个问题。没有一种方法是正确的,因此最好的选择是阅读“游戏逻辑”和“游戏对象行为”等内容。更重要的是,您需要弄清楚您正在追求什么样的交互,并考虑您将需要的状态转换。与直觉相反,我总是发现设计框架比编写实际逻辑要复杂得多。

祝你好运!

Well its usually something you do to suit your needs. There is no one right way.

For a 3D platformer game I worked on years ago I designed the editor and game logic. The game logic was all a C++ hierarchy and each object had the ability to pass messages to other objects. To activate a lever which opened a door I would simply set up a simple "trigger zone" which was a logic object in itself that, simply, checked if the user was inside the sphere (As the level was organised into certain "zones" I needn't check triggers that weren't in my current zone). The trigger would then activate the lever (and this would start the animation). The lever was then set up to activate the door once it had been pulled. As any object could be a trigger it was simple to chain the triggers together. I could even assign triggers to certain points. Such as AnimationBegin, AnimationEnd, after a certain time or it could be keyed to a specific key frames in the animation. As each object could have triggers like this it was easy to design the editor to allow you to select a trigger event and then set which object was activated when the trigger occurred. Of course these trigger could just happen keyed to an animation which allowed me to do things like synchronising object movement for more nasty traps ...

This is only one method and it worked beautifully for what we needed it for. There are many many different ways to approach this problem. No one way is correct so your best bet is to read up on things like "Game Logic" and "game object behaviours". More to the point you need to figure out what sort of interactions you are after and think about the state transitions that you will require. Counter-intuitively I've always found its significantly more complicated to design the frame work than it is to write the actual logic.

Good luck!

谢绝鈎搭 2024-10-17 19:08:34

看看这个这个页面,这里有很多游戏开发者的资源

Check out this this page, there are a lot resources for game developers

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