如何制作一款FPS游戏?

发布于 2024-07-08 16:36:16 字数 56 浏览 5 评论 0原文

我想知道如何使用 SDL 库创建 fps 游戏?

有没有什么书籍可以举例说明?

I would like to know How to create a fps-game with SDL lib?

Are there any books that explain with examples?

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

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

发布评论

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

评论(5

许一世地老天荒 2024-07-15 16:36:17

虽然不是特定于 SDL,但 NeHe OpenGL 教程是学习如何进行 3D 的绝佳起点。

如果这是您的第一款游戏,您可能希望设定低于 FPS 的目标。 使用 SDL 编写一个简单的 2D 俄罗斯方块游戏将教会您有关该库所需了解的一切。

While not SDL specific, the NeHe OpenGL tutorials are an excellent place to start for learning about how to do 3D.

If this is your first game, you'll probably want to aim lower than an FPS. Writing a simple 2D Tetris game using SDL will teach you everything you'll need to know about that library.

痴意少年 2024-07-15 16:36:17

几乎所有标题中提到的“游戏编程大师的技巧”都会向您展示如何制作 FPS 游戏。 勒莫特很喜欢它们。

编辑:忘记了那些标题。

Pretty much anything that says in the TItle the "Tricks of the Game Programming Gurus" is going to show you how to make a FPS game. LeMothe loves them.

Edit : forgot those titles.

谁的新欢旧爱 2024-07-15 16:36:16

这对于大多数开放式问题来说是胜利。 你真的可以写一本书。 但让我们确定指向正确的方向...

第一步,对于这样的项目,您需要良好的调试技能。 阅读 Steve McConnell 的《Code Complete》。 阅读全文。 投入的时间比你可以阅读/实验的任何其他东西都更值得。

获得一些游戏的源代码。 任何游戏。 确保在看到大而复杂的东西之前先看到简单的东西,并记住,当您查看任何游戏代码时,他们可能有一个联合团队投入了比您更多的时间。 重点是看代码结构。

获得 3D 数学的参考,不必那么深入,但您需要了解点积之类的东西,能够弄清楚如何在世界中为您的相机创建矩阵等。(即使您编写了 0% 的渲染代码)

(编辑)这是一本关于 3D 数学的好书3D 游戏编程和计算机图形学数学,第二版(游戏开发系列) 这不是你在大学里学到的那种,它更像是三角函数和更高级的实用概念之间的交叉:如何为自己创建一个简单的物理、高效的碰撞检测等工具箱。

您需要了解一些有关渲染和管道的知识。 SDL 可以为您提供帮助,但请确保您了解其功能的概念。

阅读有关实用系统设计的内容。 您的各种系统必须互锁。 好好想想吧。 你的系统在 C 或 C++ 中可能只是一个很好的系统,重要的是你的数据/控制如何流动的想法,而不是你模拟设计模式的完美程度(尽管这些对于粗略的设计模式也非常有用

)人工智能,不是“真正的”人工智能,而是功能性人工智能; 有一个很大的不同。 状态机非常适合入门,对于简单的 FPS 来说已经足够了。

了解一些有关估算和规划的知识。 您将没有时间去做您想要做的所有事情来正确地制作 FPS。 您必须进行分类并学习如何分类; 它们是两件不同的事情,后者更困难。 经验是粗俗最好的老师。 (尽管传奇人物麦康奈尔也有这方面的书)

拥有一个系统可以将您的游戏玩法插入到您的关卡中。 如果您只是一名程序员,那么您最好的选择是为现有的编辑程序(例如 3DS Max)编写插件。 对于程序员来说,我强烈推荐 Max,而不是 Maya。 Maya 脚本很好,但它更适合聪明的非程序员。 我发现 3DS Max 的思考更多地类似于程序员如何创建和编辑你的世界。

您可以花费数年时间来制作工具来让您正确完成此操作,因此您希望以可以快速准确地编辑的方式做事
如果您制作自己的编辑器,请将其合并到您的游戏世界中。
如果您的世界不是真正的 3D 并且您想快速制作大量关卡,您可以将关卡数据保存为类似这样的内容,这将为您节省大量时间
其中 X 是墙,其他字母是游戏对象,一个简单的解析器可以将其转换为游戏对象和世界坐标,

 xxxxxxxxxxxxxxxxxxxxxxxx
 xx..........P..........x
 xxxxxxx...........I....x
 xR....xxx...........E..x
 xx.................0xxxx
 xxxxxxxxxxxxxxxxxxxxxxxx

但这一切都取决于您的游戏。 我的观点是,你需要诉诸“贫民窟编码”,如何将游戏数据带入你的世界非常重要,你需要考虑一些既可以快速实施又可以快速使用的东西。

归根结底是你的目标是什么? 如果要学习以绝对正确的方式编写代码,则需要花费大部分时间迭代一个月前看起来还不错的代码,但现在您意识到自己的要求是什么,它真的可以使用另一遍。 不要害怕重写,通过这样做你可以学到很多东西,但是如果你的目标是功能,你可能需要弄清楚在哪里破解一些东西(比如将游戏数据和坐标嵌入到代码文件中)只要您知道自己在哪里进行了黑客攻击,并且小心地将其与您的良好代码分开,这样您就可以在有机会时返回并正确编写代码,就可以进行黑客攻击。

最重要的是,您需要决定您的目标是什么,学习还是功能,并找到两者之间的折衷方案。

this wins for most open ended question. You could literally write a book. But lets settle for pointing in the right direction...

Step one, you will need good debugging skills for a project like this. Pick up Code Complete by Steve McConnell. Read the whole thing. The time invested will pay for itself more than anything else you could read/experiment with.

Get your hands on some source code of some game. ANY game. Make sure you see something simple before you see something big and complex, and keep in mind when you look at any game code that they may have had a combined team put WAY more time into it than you will ever have. The point in this is to see code structure.

Get a reference for 3D math, doesn't have to be THAT in depth, but you will need to know stuff like dot products backwards and forwards, be able to figure out how to create the matrix for your camera in the world etc. (even if your writing 0% of the rendering code)

(edit) Here's a great book on 3D mathMathematics for 3D Game Programming and Computer Graphics, Second Edition (Game Development Series) This isn't the kind you learn in college, it's more like a cross between trig and more advanced practical concepts: How to create a toolbox for yourself of simple physics, efficient collision detection, etc.

You will need to know something about rendering, and pipelines. SDL gives you a leg up, but make sure you understand the concepts of what it's doing.

Read up about practical system design. Your various systems will have to interlock. Think it out well. Your system can be just a good in C or in C++, it's the THOUGHT that is put into how your data/control will flow that will count, NOT how perfectly you emulate design patterns (though these are very useful as well of coarse)

Fundamentals of AI, not "real" AI, but functional AI; there is a big difference. State machines are great to start with, and sufficient for a simple FPS.

Learn a little about estimation and planning. You will not have time to do everything you would want to do to properly make an FPS. You will have to both triage AND learn how to triage; they are 2 separate things, the latter being mroe difficult. Experience is the best teacher here of coarse. (though the legendary McConnell has book on this as well)

Have a system to insert your gameplay into your level. If it is JUST you as a programmer, then your best bet is to write a plug in for an already existing editing program such as 3DS Max. I would highly recommend Max over Maya for a programmer. Maya script is nice, but it is more geared toward clever non-programmers. I find 3DS Max to think more along the lines of how a programmer would about creating and editing your world.

You can spend YEARS making tools to let you do this right, so you want to do things in such a way that you can edit fast and accurately
If you making your own editor, incorporate it into your game world.
If your world is not TRULY 3D and you want to make lots of level fast you can save your level data as something like this, which will save you a lot of time
Where X is a wall, the other letters are game objects which a dirt simple parser can translate into game objects and world coordinates

 xxxxxxxxxxxxxxxxxxxxxxxx
 xx..........P..........x
 xxxxxxx...........I....x
 xR....xxx...........E..x
 xx.................0xxxx
 xxxxxxxxxxxxxxxxxxxxxxxx

But it all depends on your game. My point is that you will need to resort to "ghetto coding" how you get your gameplay data into your world is very important and you need to think of something that is both fast for you to implement AND fast with you to work with.

And what it comes down to is what is your goal here? If it's to learn to code something the absolute right way, expect to spend most of your time iterating on code that seemed decent a month ago, but now that you realize what your requirements are, it could really use another pass. Do not be afraid to rewrite, you learn a lot by doing that, but if you goal is functionality, you will probably need to figure out where to hack some things in (like embedding gameplay data nad coordinates into code files) It IS ok to hack as long as you KNOW where you have hacked, and have carefully kept it separate from your good code so you can go back and properly write the code when you get the chance.

The bottom line is, you need to decide what your goal in this is, learning, or functionality and find the happy medium between.

若沐 2024-07-15 16:36:16

fileshack 下载 quake 3 源代码并从中学习。

Download the quake 3 sources at fileshack and learn from them.

浅沫记忆 2024-07-15 16:36:16

尽管从长远来看,这篇很长的文章很有价值,但我觉得它并没有给出将内容显示在屏幕上的适当的即时动力。 以下是一些事实以及我的观点

-SDL 是一个 2D 图形库,您无法以 2D 形式编写 FPS,因此您必须使用 3D 库,无论是 DirectX 还是 openGL

-SDL 具有“同步”能力与 openGL,将其用于图形,但在该主题上没有太多在线帮助,

我建议您访问 Lazyfoo.net,这是一个绝对令人惊叹的使用 SDL 进行游戏编程的初学者资源,它向您展示了如何绘制到screen,还教你如何将其应用到游戏编程中。 完成此操作后,您将能够制作俄罗斯方块克隆或大多数其他 2D 类型游戏。

在此之后,您将为 3D 做好准备(它要复杂得多,需要更好地掌握数学,并且需要很多时间)更多代码来做更简单的事情)如果你使用 openGL,请查看 NeHe 的教程,他们目前正在开发一套新的教程,将 SDL 与 openGL 结合使用,因为旧的教程虽然很有价值,但编码相当糟糕并且使用 windows( win32) API

请记住,游戏开发是您会遇到的要求最高且回报最高的编程之一,祝您好运

Although the very long post is valueable in the long run, I feel it doesn't give the proper instant motivation of getting things on screen. Here's some facts, along with my opinion

-SDL is a 2D graphics library, you can't write an FPS in 2D, therefore you have to go with a 3D library, either DirectX, or openGL

-SDL has the ability to "sync" with openGL, using it for graphics, but there's not a whole lot of help online for that topic

I suggest you go to Lazyfoo.net, which is an absolutly amazing beginner's resource for game programming with SDL, it shows you how to draw to the screen, but also teaches you how to apply this to programming games. After going through this, you'll be able to make a tetris clone, or most other 2D type games

After this, you'll be ready for 3D(it's a lot more complex, requires a better grasp of math, and takes a lot more code to do simpler things) if you go with openGL, check out NeHe's Tutorials , they're currently working on a new set, using SDL with openGL, because the older tutorials, although valueable, are coded rather badly and use the windows(win32) API

keep in mind, game development is one of the most demanding, and rewarding programming you'll come across, so good luck

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