如何制作第一人称射击游戏? [英] How to create a FPS game?

查看:330
本文介绍了如何制作第一人称射击游戏?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

有没有用示例解释的书?

解决方案

这对于大多数开放式问题都是有帮助的.你可以从字面上写一本书.但是让我们为指向正确的方向做好准备...

第一步,您将需要一个类似这样的项目的良好调试技能.接听史蒂夫·麦康奈尔(Steve McConnell)的《代码完成》(Code Complete).阅读全部内容.投入的时间将比其他您可以阅读/体验的东西所付出的时间要多.

动手掌握某些游戏的源代码.任何游戏.在看到大而复杂的事物之前,请确保先看到简单的事物,并牢记当您查看任何游戏代码时,他们可能已经将一个合并的团队投入了比以往更多的时间.重点是查看代码结构.

获取有关3D数学的参考,不一定要深入,但您需要了解点积的东西,才能弄清楚如何为世界上的相机创建矩阵等等(即使您编写了0%的渲染代码)

(编辑)这是一本关于3D数学的好书

了解一些有关估计和计划的知识.您将没有时间去做所有您想做的事情来正确制作FPS.您将必须进行分类并学习如何分类.它们是2个独立的事物,后者很难解决.经验是这里最好的老师. (尽管传奇的麦康奈尔(McConnell)也有关于此的书)

拥有一个系统,可将您的游戏玩法插入您的关卡中.如果您只是程序员,那么最好的选择是为一个已经存在的编辑程序(例如3DS Max)编写插件.对于程序员,我强烈建议Max胜过Maya. Maya脚本不错,但更适合聪明的非程序员.我发现3DS Max在程序员如何创建和编辑您的世界方面会更多地思考.

您可以使用YEARS制作工具来正确执行此操作,因此您希望以一种可以快速,准确地进行编辑的方式进行操作 如果您创建自己的编辑器,请将其纳入您的游戏世界. 如果您的世界不是TRULY 3D,而您想快速进行很多关卡,则可以将关卡数据保存为这样的格式,这将节省大量时间 在X是墙的情况下,其他字母是游戏对象,简单的解析器可以将它们转换为游戏对象和世界坐标

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

但这全取决于您的游戏.我的观点是,您将需要使用贫民区编码",如何将游戏数据带入您的世界非常重要,并且您需要考虑一些既可以快速实现又可以与您一起快速使用的东西. /p>

这到底是您的目标是什么?如果要学习以绝对正确的方式编写代码,可以期望将大部分时间花在一个月前看起来不错的代码上,但是现在您意识到自己的要求了,它实际上可以使用另一遍.不要害怕重写,这样做会学到很多东西,但是如果您的目标是功能,那么您可能需要弄清楚在哪里破解某些东西(例如将游戏数据和坐标嵌入到代码文件中).只要知道了被黑客入侵的地方,并仔细地将其与良好的代码分开,就可以进行黑客入侵.

最重要的是,您需要确定您的目标是学习,功能还是在两者之间找到快乐的中介.

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

Are there any books that explain with examples?

解决方案

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.

这篇关于如何制作第一人称射击游戏?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆